interpreter: Skip the phi-node scan after most statements #65167
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 404 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
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.359
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #65167"
general
weight: 0.35
Keno
After every statement the interpreter called
eval_phi, which scans the statements from the next one onwards for a phi block. A statement that is an expression, a branch, a return, a PhiC, an Upsilon or an SSA value ends that scan before it finds anything, and almost every statement in lowered code is one of these.eval_phiis now an inline wrapper that checks the first statement itself and calls the scan, renamedeval_phi_slow, only when a phi block might start there. Both use the same helper,ends_phi_block, to decide where a phi block ends, so the result is unchanged. Fall-through and branch targets both go through this one call site.Benchmark
Three interpreted microbenchmarks (a loop of integer arithmetic, a loop calling a small function, a loop allocating a
Ref), each run under--compile=minwithBase.Experimental.@compiler_options compile=min. Measured withperf stat -e instructions:u,cycles:u, pinned to one core withtaskset, on an AMD EPYC 9354. Each process ran either n = 1 or n = 3,000,000 iterations, and the median n = 1 count was subtracted to remove startup. 5 alternating reps per build. Baseline is the same master commit without this change. Values are per iteration, median [min–max]:| benchmark | metric | master | this PR | change |
|---|---|---|---|---|
| loop | instructions | 8125.8 [8125.8–8125.8] | 7844.9 [7844.9–7844.9] | −3.46% |
| loop | cycles | 1677.0 [1654.3–1856.4] | 1624.3 [1589.0–1654.0] | −3.14% |
| calls | instructions | 6439.9 [6439.9–6441.9] | 6116.0 [6115.9–6116.0] | −5.03% |
| calls | cycles | 1327.4 [1317.1–1374.9] | 1269.4 [1262.1–1276.3] | −4.37% |
| allocs | instructions | 6854.5 [6854.5–6855.4] | 6559.5 [6559.5–6559.5] | −4.30% |
| allocs | cycles | 1412.2 [1404.7–1443.4] | 1344.4 [1338.8–1373.1] | −4.80% |
The saving comes entirely from the statement-kind check. A build whose wrapper only checks
to >= nsbefore callingeval_phi_slowis 1.1% above master in instructions on all three benchmarks, and one that always callseval_phi_slowis 0.2% above master.Testing
interpreter,core,exceptionsandCompiler/ssairpass.Compiler/ssairincludesCompiler/test/interpreter_exec.jlboth normally and undercompile=min, and that file runs hand-built thunks with phi blocks afterGlobalRef/QuoteNodestatements and after branches.--compile=min,core,iterators,tuple,dict,exceptions,arrayops,strings/basicandfunctionalgave identical pass/fail/broken counts and identical failing test locations on master and on the first version of this branch;iterators,tupleandfunctionalgive the same results again on the current version. Some of these files already fail under--compile=minon master, andcore.jlsegfaults at the same line on both builds.OpaqueClosures built withdo_compile=falsefrom optimizedIRCodecontainingPhiNodes (two loop functions) give the correct results. Under gdb (on the first version of this branch) they run in the interpreter and evaluate a nonempty phi block from the new call site.make -C src analyze-interpreteris clean.This patch was written with Claude Code.