← Back to Pull requests

types: memoize structural facts about a UnionAll in a flag word #63778

Open
Keno opened this pull request with 813 lines diff across 8 files
View on GitHub
Keno Keno commented on Oct 13, 2026 04:52 UTC
Author

This backports the flags word from #63530. According to Claude this is -27% load time on using ReverseDiff, although as repeatedly stated elsewhere the real bug is doing so much subtyping work at load time in the first place.

Putting this here to get accurate TTFX numbers on #63770.

Diff: 813 lines (+425 / -388) across 8 files Reviewer: vtjnash Review duration: 7514m
All Vouch review confidence checks passed
Residual risk 0.09 = Change Risk (0.58) × (1 − Review Confidence (0.85)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.58 · 813 lines diff across 8 files
0.58
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.89 · 5 substantive comment(s)
0.89
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
85%
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.400
Ai Authored ai_authored
0.050
Real PR Conversation Timeline
6 items
KristofferC KristofferC commented on Oct 13, 2026 19:25 UTC
Contributor

This has very good numbers... Can we just get this first?

IanButterworth IanButterworth commented on Oct 13, 2026 20:17 UTC
Contributor

The make loading faster stack avoids this this work entirely https://github.com/JuliaLang/julia/pull/63657

---

using ReverseDiff load time, median of 6 fresh processes each (ABBA x3, macOS, caches already built):

| Arm | Load | vs master |
|---|---|---|
| master a03643856e (stack base) | 1.284 s | |
| master + this PR | 0.948 s | -26% |
| stack top (#63657) | 0.136 s | -89% |
| stack top + this PR | 0.136 s | -89% |

The stack skips the work this PR speeds up.

KristofferC KristofferC commented on Oct 14, 2026 12:59 UTC
Contributor

The make loading faster stack avoids this this work entirely

Had Claude look into this a bit:

The combination still helps. Precompile and first-call times barely move. The real gain is load time in sessions with several packages, where the stack's replay falls back to live matching.

I ran #63657 (top of the loading stack, 0aeaa0fc95) against #63657 with #63778 merged in (a6d2e1caa9, merged cleanly). Each arm had its own depot, there were 8 alternating reps, and every timing is a fresh process.

┌────────────────────────────────────────┬───────────┬──────────────┬──────────┬──────────────┐
│                 Metric                 │ stack (s) │ + #63778 (s) │ Δ median │ Paired range │
├────────────────────────────────────────┼───────────┼──────────────┼──────────┼──────────────┤
│ using ReverseDiff                      │ 0.243     │ 0.242        │ −0.4%    │ −2% … +8%    │
├────────────────────────────────────────┼───────────┼──────────────┼──────────┼──────────────┤
│ using DataFrames, OrdinaryDiffEq       │ 2.141     │ 1.912        │ −10.7%   │ −12% … −8%   │
├────────────────────────────────────────┼───────────┼──────────────┼──────────┼──────────────┤
│ using ReverseDiff after DataFrames+ODE │ 1.053     │ 0.849        │ −19.4%   │ −20% … −19%  │
├────────────────────────────────────────┼───────────┼──────────────┼──────────┼──────────────┤
│ first ReverseDiff.gradient             │ 0.606     │ 0.604        │ −0.4%    │ −2% … +2%    │
├────────────────────────────────────────┼───────────┼──────────────┼──────────┼──────────────┤
│ first ODE solve(…, Tsit5())            │ 1.186     │ 1.191        │ +0.4%    │ −1% … +3%    │
├────────────────────────────────────────┼───────────┼──────────────┼──────────┼──────────────┤
│ compilecache(ReverseDiff)              │ 12.87     │ 12.32        │ −4.3%    │ −5% … −2%    │
├────────────────────────────────────────┼───────────┼──────────────┼──────────┼──────────────┤
│ compilecache(DataFrames)               │ 22.37     │ 22.64        │ +1.2%    │ −1% … +4%    │
└────────────────────────────────────────┴───────────┴──────────────┴──────────┴──────────────┘

  • Ian's result reproduces. Loading ReverseDiff alone is neutral, because replay skips nearly all the type work there.

  • Mixed sessions still gain a lot. When unrelated packages are loaded together, replay often falls back to live matching or to #63657's disjoint-intersection check. That's where #63778 still saves 200–230 ms (−11% and −19%), and the spread between reps is tight.
  • So what Ian measured is the one case where the stack makes #63778 redundant. Once a session has more than one package family loaded, the gain comes back.

    KristofferC KristofferC commented on Oct 14, 2026 14:12 UTC
    Contributor

    This needs a rebase (but the PR is not allowed to be changed by maintainers so I couldn't do it myself)

    vtjnash vtjnash commented on code on Oct 14, 2026 15:21 UTC
    Code Review
    src/julia.h:1
    @@ -638,7 +638,20 @@ typedef struct JL_GC_TRACKED_TYPE {
         JL_DATA_TYPE
         jl_tvar_t *JL_NONNULL var;
         jl_value_t *JL_NONNULL body;
    +// hidden fields (not part of the Julia-visible layout, so a UnionAll must be

    Why do we need to hide this? Hidden fields are annoying, and it seems reasonable to make this visible (unless you think it'll get deleted again with other work in changing representations?)

    Reviewers
    Assignees
    Keno Keno
    Labels
    risk: low confidence: 85.4% 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: 58.2% (MEDIUM) · Higher = larger blast radius
    58.2%
    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: 85.4% · Lower = rushed or shallow review
    85.4%
    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: 8.5% · Safe to merge
    8.5%