perf(interp): fold loop branch legs into native back-edges#160
Conversation
|
Warning Review limit reached
Next review available in: 7 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: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughChangesNative loop-leg folding
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant NativeLoop
participant tracePlan
participant arm64Lowerer
participant Interpreter
NativeLoop->>tracePlan: process loop leg and header cut
tracePlan->>arm64Lowerer: emit native back-edge or fallback edge
arm64Lowerer->>NativeLoop: reuse matching continuation or schedule work
NativeLoop->>Interpreter: trapNone or trapFallback
Interpreter->>Interpreter: exhaust module or tear down frame
Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@interp/jit_arm64_test.go`:
- Around line 2671-2680: The native-entry assertion in the test currently
aggregates entries from both the scan and fill loops, so it does not verify
scan-loop behavior. Update the metrics iteration around profile.Metrics() to
filter entries using the scan loop’s identifying func/ip/kind labels, then apply
the existing count assertions only to that scoped metric.
In `@interp/jit_plan.go`:
- Around line 626-634: Restrict the shortcut in the trace split logic around the
hot-edge check to the plan’s own depth-0 loop cut by applying the same
entryLoop, depth, and plan-header conditions used near Lines 564-568. Ensure
matching branch/cut pairs at depth > 0 follow fallback instead of folding onto
the native loop back-edge, and add a regression case covering that inlined-frame
scenario.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 13c9e2c3-1ff9-4b5f-aa48-19bc79f98f2e
📒 Files selected for processing (9)
AGENTS.mddocs/benchmarks.mddocs/jit-internals.mdinterp/interp.gointerp/jit.gointerp/jit_arm64.gointerp/jit_arm64_test.gointerp/jit_plan.gointerp/jit_plan_test.go
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #160 +/- ##
==========================================
+ Coverage 29.70% 29.74% +0.03%
==========================================
Files 86 86
Lines 60357 60386 +29
==========================================
+ Hits 17930 17962 +32
Misses 41156 41156
+ Partials 1271 1268 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Record native loop fallback exits as branches so loop anchors recompile
through the side-exit machinery, fold partial legs whose cut lands on the
plan's own header into the committing-flush native back-edge, and share
identical scheduled continuations so folded legs that cycle through a loop
nest converge instead of exhausting the continuation limit. Handle the
trapNone return a folded RETURN or completed leg produces in the loop
wrapper: tear the frame down like call() for a function loop and mark the
module frame exhausted like start() for top-level code.
Sieve(256) drops from 4.19us to 1.61us (default) and 4.17us to 1.57us
(eager jit) on M4 Pro interleaved A/B; scan-loop native entries fall from
~55 to ~1 per run. All other benchmarks stay at parity.
Closes #155
Summary by CodeRabbit
Sieve(256)benchmark figures based on recent re-measurements.