refactor: align JIT profiling lifecycle and reporting#145
Conversation
📝 WalkthroughWalkthroughAdds lifecycle-aware JIT profiling across collection, tracing, cache scheduling, compilation, ARM64 exits, native wrappers, and CLI reporting. The ChangesJIT lifecycle profiling
Estimated code review effort: 5 (Critical) | ~120 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #145 +/- ##
==========================================
+ Coverage 26.98% 27.42% +0.43%
==========================================
Files 83 86 +3
Lines 59196 59883 +687
==========================================
+ Hits 15974 16421 +447
- Misses 41999 42233 +234
- Partials 1223 1229 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
cli/profile_report.go (1)
107-115: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMove comparison helpers below their caller.
entry.lessandmissRow.lessprecedeprofile.jitRows. Move them belowjitRowsor inline them.As per coding guidelines, “Go declarations should follow the repository's declaration-order rule: callers before callees.”
🤖 Prompt for 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. In `@cli/profile_report.go` around lines 107 - 115, Move the entry.less and missRow.less comparison helpers below their caller profile.jitRows, preserving their existing comparison logic and behavior. Do not change unrelated declarations or inline the helpers unless necessary.Source: Coding guidelines
🤖 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/interp_test.go`:
- Around line 3587-3604: Update the profiling test around New and the
ErrFrameOverflow assertion to construct a prof.Profiler and pass it through
WithProfiler instead of assigning i.samples and i.profile directly. Close the
interpreter before inspecting the profiler’s flushed metrics, while preserving
the existing metric assertions for JIT emits, native entries, exits, and yields.
In `@interp/jit_arm64.go`:
- Around line 3219-3223: Update the guardRC and guardBoxable calls in arrayGet,
arraySet, structGet, and structSet to use a value-labeled ExitGuardValue failure
path instead of the shape-labeled fail path; preserve the existing bounds and
struct kind failure labels.
In `@interp/pool_test.go`:
- Around line 350-379: Strengthen the metric assertions in the test around the
hotCompiles, sideExitCompiles, guardExits, attempts, and emits checks to
validate the only-winners invariant rather than merely lower bounds. Compare
emitted compile records with the corresponding successful cache publication or
claim count, using exact equality so duplicate accounting by losing contenders
causes the test to fail.
---
Nitpick comments:
In `@cli/profile_report.go`:
- Around line 107-115: Move the entry.less and missRow.less comparison helpers
below their caller profile.jitRows, preserving their existing comparison logic
and behavior. Do not change unrelated declarations or inline the helpers unless
necessary.
🪄 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: b588c153-0325-490f-a844-9c112f4c6e83
📒 Files selected for processing (24)
cli/profile.gocli/profile_collect.gocli/profile_report.gocli/profile_report_test.gocli/repl.gocli/repl_test.godocs/jit-internals.mddocs/profile.mddocs/superpowers/plans/2026-07-13-profile-report.mddocs/superpowers/specs/2026-07-13-profile-report-design.mdinterp/cache.gointerp/cache_test.gointerp/interp.gointerp/interp_test.gointerp/jit.gointerp/jit_arm64.gointerp/jit_arm64_test.gointerp/pool_test.gointerp/trace.gointerp/trace_test.goprof/collector.goprof/jit.goprof/jit_test.goprof/prof_test.go
💤 Files with no reviewable changes (1)
- interp/cache_test.go
7d3ce48 to
25947b0
Compare
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
interp/interp.go (1)
763-820: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick winRestore caller-before-callee declaration order.
compile/sharedare declared before their later callers insafepoint(Line 976) and the side-exit path (Line 1191). Reorder these declarations so every caller precedes its callee, includingsharedbeforecompileif applicable. As per path instructions, Go declarations must follow the repository’s caller-before-callee rule.🤖 Prompt for 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. In `@interp/interp.go` around lines 763 - 820, Reorder the Interpreter methods so each caller appears before its callee according to the repository convention: move shared before compile if shared calls compile or otherwise ensure the caller/callee chain from safepoint and the side-exit path is ordered correctly. Keep the implementations unchanged and only adjust declaration placement.Source: Path instructions
🧹 Nitpick comments (1)
interp/interp.go (1)
857-864: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse a tagged switch for
entry.kinddispatch.This three-way enum dispatch should use
switch entry.kindinstead of anif/else ifchain with a catch-all branch, making unsupported kinds easier to handle intentionally. This corresponds to staticcheck QF1003.🤖 Prompt for 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. In `@interp/interp.go` around lines 857 - 864, Replace the entry.kind if/else-if/catch-all dispatch with a tagged switch in the surrounding interpreter logic, using explicit cases for entryLoop, entryModule, and the regular call behavior. Preserve the existing arguments, counter calculation, and assignment to i.code[a.addr][a.ip], while making the default or unsupported-kind handling intentional.Source: Linters/SAST tools
🤖 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.
Outside diff comments:
In `@interp/interp.go`:
- Around line 763-820: Reorder the Interpreter methods so each caller appears
before its callee according to the repository convention: move shared before
compile if shared calls compile or otherwise ensure the caller/callee chain from
safepoint and the side-exit path is ordered correctly. Keep the implementations
unchanged and only adjust declaration placement.
---
Nitpick comments:
In `@interp/interp.go`:
- Around line 857-864: Replace the entry.kind if/else-if/catch-all dispatch with
a tagged switch in the surrounding interpreter logic, using explicit cases for
entryLoop, entryModule, and the regular call behavior. Preserve the existing
arguments, counter calculation, and assignment to i.code[a.addr][a.ip], while
making the default or unsupported-kind handling intentional.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: e3738f33-8589-4133-af00-03f701ea48c5
📒 Files selected for processing (6)
cli/profile.gocli/repl.gointerp/interp.gointerp/jit.gointerp/jit_arm64_test.goprof/jit_metrics.go
🚧 Files skipped from review as they are similar to previous changes (5)
- cli/repl.go
- interp/jit_arm64_test.go
- prof/jit_metrics.go
- cli/profile.go
- interp/jit.go
Summary
WithLocalprofiler option and keep the interpreter's sampling collector internalWithProfiler(nil)disable observable profilingcli/profile.goVerification
go test -race ./...go vet ./...git diff --checkSummary by CodeRabbit
.profileoutput with normalized, ranked “hot” tables plus JIT summaries and miss/exit sections.