← Back to Pull requests

aotcompile: Reduce peak memory use further #63363

Closed
unknown closed this pull request without merging on Sep 30, 2026 19:57 UTC
View on GitHub
unknown unknown commented on Sep 25, 2026 21:08 UTC
Author

I've changed my mind on this because of how useful it would be to have this in before the 1.14 freeze. I still plan on replacing the partitioning functionality in order to get this working with the objcache, but this is worth having now. This is similar to:

  • #59348, but without the temporary files.

  • #62182, but with additional memory savings and a simpler way of picking how many shards we'll use.
  • The new heuristic is supposed to be simple, derived from testing on Windows (32 and 64 bit), since that's the platform where memory pressure hurts us the most: On 32 bit, we always use a single worker thread. Everywhere else, we use jl_effective_threads(), with or without the jobserver (seemed to be mostly pointless to keep the /2 thing around now that we have that). We try to give each worker one shard, but refuse to make a shard with weight less than 10k (too much overhead) or weight greater than 250k (to avoid high memory pressure). If we're forced to make more shards than workers because it is bigger than num_workers * 250k, make as many shards as the first multiple of num_workers that would bring the shard weight below 250k.

    The change also fixes the crash we'd get when a shard doesn't contain any fvars or gvars (doesn't happen with the current heuristic, but nice to have).

    Lastly, I've added a "fast path" when the jl_native_code_desc_t owns the ThreadSafeContext associated with the ThreadSafeModule: when that's true, we can avoid the withModuleDo that keeps the LLVM context around until after we've compiled everything, reducing the peak memory use some more.

    <img width="2200" height="1080" alt="image" src="https://github.com/user-attachments/assets/66f89fe9-c1b1-4767-9cd8-8702d1415aac" />

    Assisted-by: Claude:claude-opus-5.5

    Diff: 224 lines (+168 / -56) across 2 files Reviewer: xal-0 Review duration: 7129m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 224 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.324
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #63363"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.9% (MEDIUM) · Higher = larger blast radius
    36.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 14.6% · Safe to merge
    14.6%