Repository navigation
Count machine code moves in IsolateBase's code statistics - #8515
Conversation
Adds CodeStatistics::machineCodeMoveCount: how many times the garbage collector moved a block of JavaScript or Wasm machine code, which V8 reports as a CODE_MOVED JIT code event. Moves of bytecode aren't counted. Together with jitCodeCount and wasmCodeCount, this counts the lines a perf map built from JIT code events would get, since both additions and moves add a line. V8 compacts code space only when that frees a whole page, so the test runs with --compact-on-every-full-gc, in its own binary, since the flag applies to the whole process. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💬 Approved with comments — The implementation and test look correct. The one note is an INFO: the CodeStatistics overview comment, which says it counts only additions, is now out of date.
Findings: 1 info (1 is an inline comment on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
📝 Documentation: 💬 1 info
The CodeStatistics overview comment is stale now that the struct has a move counter.
Recommendation: 💬 Optional Nits
- [INFO] CodeStatistics overview comment (setup.h:514-516) says the struct only counts generated-code additions; the new move counter is neither. (
src/workerd/jsg/setup.h:528)
View full review
src/workerd/jsg/setup.h:514-516: the struct-level comment callsCodeStatisticstotals of code V8 has generated and says it "Only counts additions". The newmachineCodeMoveCountcounts GC moves, not generated code.
✅ All other checks passed
📋 Code Quality: ✅ LGTM
The counter only goes up for code already tracked in codeMap, skips BYTE_CODE, and uses the same relaxed atomic pattern as the other statistics. The BUILD glob turns the new test into its own binary, so the process-wide GC flag does not affect other tests.
Reviewed commit: 912cdfd5
Adds
CodeStatistics::machineCodeMoveCounttojsg::IsolateBase::getCodeStatistics(): how many times the garbage collector moved a block of JavaScript or Wasm machine code (V8'sCODE_MOVEDJIT code event). Moves of bytecode aren't counted.Why: together with
jitCodeCountandwasmCodeCount, this counts the lines a perf map built from JIT code events would get (#8163), since each addition and each move adds a line. Edgeworker will export it to Prometheus to measure how fast such a map grows in production.Testing: V8 compacts code space only when that frees a whole page, which a test's small heap never does, so the new
code-move-testruns with--compact-on-every-full-gcin its own binary, since the flag applies to the whole process. The GC has to run within the same evaluation as the optimized function:Evaluator::expectEval()creates a new context for each evaluation, so otherwise the code is already dead and nothing moves. Passes 5 of 5, as doessetup-test.🤖 Generated with Claude Code