jit: remove dead loop-trace operand-stack seed from run_perfn_walk#520
Conversation
The non-bridge arm of the argboxes seeding in run_perfn_walk copied sym.registers_r operand-stack colors (nlocals..nlocals+depth) into the walk register file and stamped their concrete pointers from the live frame's locals_cells_stack_w. Since the codewriter's Instruction::ForIter handler reloads the iterator through getarrayitem_vable_r on every iteration (fab987c), the ForIterNext residual consumes that in-loop read instead of an entry register, and the seed no longer has a consumer. A/B over kept_stack_deep_var_{condexpr,nested_call,shortcircuit, shortcircuit_mutate}, foriter_call_body, foriter_loadglobal_body, while_is_none, int_loop, nested_loop, fib_loop shows identical stdout, identical abort/decline census, and identical compile stats with the arm removed. Both bridge seed arms are unchanged. Assisted-by: Claude
|
Warning Review limit reached
Next review available in: 17 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🤖 Codex parity reviewStatic analysis of this diff vs the local RPython/PyPy sources (commit 5f3c49c). 1. Regressions to PyPy parity introduced by this patch
2. Other mismatches introduced by this patchNone. 3. Pre-existing mismatches (already present before this patch)
4. Structural adaptations
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c02c3b47f2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Loop-trace entry seeds no operand-stack colors. The codewriter's | ||
| // `Instruction::ForIter` handler emits `getarrayitem_vable_r` to reload | ||
| // the iterator from the virtualizable on every iteration, so the | ||
| // residual consumes that in-loop read rather than an entry register. |
There was a problem hiding this comment.
Preserve non-iterator stack inputs at loop entry
This only accounts for FOR_ITER's TOS iterator, but loop headers can have other live operand-stack values. A hot list comprehension enters the loop with the result list below the iterator, and Instruction::ListAppend peeks that accumulator from current_state.stack and passes it as the first jit_list_append residual arg (see pyre/pyre-jit/src/jit/codewriter.rs:9953-9981); it is not reloaded by the ForIter-only getarrayitem_vable_r. With the non-bridge stack seed removed, that lower stack value is left OpRef::NONE at a FOR_ITER loop entry, so the LIST_APPEND fold/residual aborts instead of compiling hot list-comprehension loops.
Useful? React with 👍 / 👎.
Design cleanup following the gh#152 per-iteration FOR_ITER reload (#436): the walk-side loop-trace operand-stack seed no longer has a consumer.
Change
run_perfn_walk's argboxes seeding had a non-bridge arm that copiedsym.registers_roperand-stack colors (nlocals..nlocals+depth) into the walk register file and stamped their concrete pointers from the live frame'slocals_cells_stack_w. Its stated justification — "without this, aForIterNext(iterator)residual declines execution" — predates #436: since the codewriter'sInstruction::ForIterhandler reloads the iterator throughgetarrayitem_vable_ron every iteration (thepeekvalue()port, pyopcode.py:1303-1304 / jtransform.py:760-767), the residual consumes that in-loop read instead of an entry register. Thenlocals+depthslot→color shortcut in this seed is also the mechanism class that produced the original color mis-seed the reload eliminated.Both bridge seed arms (
bridge_registers_rcolor seeding,bridge_stack_oprefsslot seeding) are unchanged — they serve bridge-resume paths, not loop entry.Evidence (A/B, arm neutralized vs baseline)
Over
kept_stack_deep_var_{condexpr,nested_call,shortcircuit,shortcircuit_mutate},foriter_call_body,foriter_loadglobal_body,while_is_none,int_loop,nested_loop,fib_loop: identical stdout, identicalPYRE_FBW_DEBUG_ABORTcensus (zero new aborts/declines), identicalMAJIT_STATScompile stats (loops_compiled/bridges_compiled/loops_aborted/guard_failures).Verification
python3 pyre/check.py: dynasm 163/163, cranelift 163/163, wasm 162/162 (re-run after rebase onto Fix #498 inlined-closure freevar+branch miscompile; bytearray repeat/seq dunders #512)PYRE_NO_JITbit-exact on the 7 synth benches above at the rebased HEADcargo test -p pyre-jit-trace: 284 passed / 0 failed;cargo test -p pyre-jit: 314 passed / 0 failed🤖 Generated with Claude Code