inference: Key const-prop cache entries by their constant arguments #64707
All Vouch review confidence checks passed
Residual risk 0.03 = Change Risk (0.39) × (1 − Review Confidence (0.91)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 81 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.91 · 3 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.264
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
4 items
It is kind of hard to understand what property these tests actually test. If the effect of this is performance, we could maybe add an entry to https://github.com/JuliaCI/julia-ci-benchmarks`
yeah. https://github.com/JuliaCI/julia-ci-benchmarks/pull/1
I'll let the TTFX job finish here then remove the test
TTFX no change. I scaled the test back.
KristofferC
IanButterworth
Claude:
---
Inference time is quadratic in the number of distinct constants a
MethodInstanceis const-propagated with. This caused the coverage hang in #64701, where 100sincalls create about 65,000 cache entries on about 110MethodInstances (7,829 on-(::Float64, ::Float64)alone).MethodInstance, about 45% of samples at 100 calls. Lookups for non-constant results also walked past those entries.MethodInstanceand its constant arguments. The full comparison still runs on each candidate.Boolis left out of the key: a conditional can be lattice-equal to aBoolconstant, so keying on it would miss matches, including cached rejections that stop a const-prop being retried.code_typedof a function with N constantsincalls, on a coverage build ofad7c34a1c3(macOS aarch64,--code-coverage=all, single runs):| N | master | this PR |
|---|---|---|
| 100 | 29.18 s | 7.30 s |
| 200 | over 150 s (on
996bec08) | 14.16 s || 1000 | not measured | 93.74 s |
Compiler/inlinewith its 1000sincalls goes from still stuck after 20 minutes (on996bec08) to 1m55s, with the same pass and fail counts as #64703 at 10 calls. That test change is independent of this one and can merge first.Checks
Compilertests pass on a regular build (macOS aarch64).true. This is a sample, and an earlier version of the key also passed it apart from that added case.isbitsconstants only. The second commit makes that change and can be dropped if hashing non-isbitsvalues costs too much.Regular builds (
inferenceandcompilercategories of julia-ci-benchmarks, againstad7c34a1c3, 3 blocks, Apple M5 Pro): no regressions, and a test-only control build flags nothing.infer_many_constprop_entries(added in JuliaCI/julia-ci-benchmarks#1): -63.3% instructionsinfer_many_method_matches: -4.2%infer_many_opaque_closures: -2.9%TTFX on this PR found no robust regressions or improvements (39 tasks, 2 blocks).
The remaining cost is linear, but each
sinstill inlines about 5,300 statements under coverage. External packages that read theindexfield or constructInferenceCachepositionally haven't been checked.Reviewed with Codex (
gpt-6-astra), which found theBoolproblem, and Fable 5.1, which suggested the non-isbitskeys.Written with Claude Code (Opus 5.5).