Skip to content

perf(jit): read each native exit through a pointer - #317

Merged
siyul-park merged 2 commits into
mainfrom
perf/jit-exit-pointer
Nov 10, 2026
Merged

siyul-park merged 2 commits into
mainfrom
perf/jit-exit-pointer

Conversation

@siyul-park

@siyul-park siyul-park commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • settle reads the exit as &entered.Exits[ctx.Exit()]; every interp consumer (callout, bridge, box, materialize, reenter, replay, nests, callee, target, the deopt closures, feedback.record) takes *jit.Exit.
  • The per-exit metric label (Kind.String()) is built only when a profiler is attached; metric already returned early without one.

Why

pprof of string-build (jit): native code is 11% of the time; settle copying the ~240-byte jit.Exit per exit (160 ms flat at the load, 110 ms at the callout argument) plus the label (90 ms) were ~10% of 3.45 s. string-build takes ~5100 exits per Run.

Safety

A Code's Exits is filled once from slices.Clone at build (internal/jit/code.go) and never written afterwards; no consumer mutated its copy. Retire/invalidate/recompile swaps *Code, never edits its exits. -gcflags=-m: no new heap moves. Independent Opus review: no findings.

Evidence

Local interleaved A/B (M4 Pro, 6 rounds, base 4eb0da7): string-build -23.8% (p=0.009), fannkuch -10.6% (p=0.041), binary-trees and allocation-graph ~. B/op and allocs/op unchanged. Local spread is wide; CI A/B decides.

Validation

  • go test ./interp ./internal/...
  • make check, git diff --check (pre-commit)

No docs change: no documented contract names the exit's passing convention.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved the consistency of JIT exit handling and aligned exit metric reporting with profiler availability. These changes do not alter user-facing functionality.

settle copied the ~240-byte jit.Exit on every native exit and copied it
again into callout, bridge, box and the deopt closures. string-build
takes about 5100 exits per Run, and pprof put the copies at ~8% of its
time. Every consumer only reads the exit, and a Code's Exits are never
written after it is built, so they now take *jit.Exit.

The per-exit metric also built its label (Kind.String) with no profiler
attached; it is now built only when one is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e559cd66-2972-474a-bd53-b84194202021

No actionable comments were generated in the recent review.

Walkthrough

JIT exit-handling callbacks and helpers now accept *jit.Exit pointers instead of values. Feedback recording also accepts an exit pointer. The settle path records exit metrics only when an interpreter profiler is present.

Changes: JIT exit handling

Layer / File(s) Summary
Pointer-based exit handling
interp/jit.go, interp/feedback.go
JIT callbacks and helpers, plus feedback.record, now accept exit pointers. settle records exit metrics only when an interpreter profiler is present.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Merge Risk: Minimal · previous review f8518

JIT exits are read through pointers, and metric labels are skipped without a profiler. No merge-blocking issue was identified.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: reading each native JIT exit through a pointer.
Description check Passed The description explains the changes, rationale, safety considerations, performance evidence, and validation. It does not use the template headings or include a related-issues section, but it is mostl…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the changes, rationale, safety considerations, performance evidence, and validation. It does not use the template headings or include a related-issues section, but it is mostly complete.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 44fe4679-ee16-4b14-b75a-a888c226b137
Commits

Reviewing files that changed from the base of the PR and between 4eb0da7 and f851822.

Files selected for processing: 2

  • interp/feedback.go
  • interp/jit.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@siyul-park
siyul-park merged commit 2341cb2 into main Nov 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant