types: memoize structural facts about a UnionAll in a flag word #63778
This has very good numbers... Can we just get this first?
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.
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% │
└────────────────────────────────────────┴───────────┴──────────────┴──────────┴──────────────┘
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.
This needs a rebase (but the PR is not allowed to be changed by maintainers so I couldn't do it myself)
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?)
vtjnash
Keno
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.