Repository navigation
perf: keep CPU profiler active across bounded capture windows - #5112
Merged
ymichael merged 1 commit intoOct 7, 2026
Merged
Conversation
ymichael
deleted the
bb/perf-pr-keep-the-cpu-profiler-running-thr_jj8pzqt5hi
branch
October 7, 2026 18:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
Performance diagnostics stopped and restarted V8's CPU profiler every 30 seconds. Restarting rebuilt its code map, causing recurring event-loop stalls in a large process. Stall detection logged the delay, but profiler operations were not instrumented, so the longest measured work could misleadingly name an unrelated heartbeat that took only 1 ms during a two-second stall.
What changed
Start the next named capture before ending the current one so V8 keeps its profiler active across bounded windows. Only two diagnostic captures briefly overlap; sampling, file limits, retention, and the final partial save remain. Initial activation and final teardown still run on the server thread.
Measure profiler start, completion, and serialization through the server's synchronous work tracker. Stall logs now explicitly report
unattributedwhen the longest measured operation cannot explain the delay, allowing one sampling interval of tolerance. Otherwise they name acandidate, which still requires confirmation from profile stacks. The debugging guide documents the handoff and attribution fields. No server/daemon wire, SDK, or CLI contracts change.How you verified
pnpm exec turbo run test --filter=@bb/server -- test/system/event-loop-stall-monitor.test.ts test/system/performance-diagnostics.test.ts: 16 tests pass.pnpm exec turbo run test --filter=@bb/process-utils -- test/performance-diagnostics.test.ts: 4 tests pass.pnpm exec turbo run typecheck lint --filter=@bb/server --filter=@bb/process-utils, targeted server lint, andgit diff --checkpass.pnpm start:worktree --perf-diagnosticsand enabled the experiment in isolated dev data. Actual captures arrive every 30 seconds with approximately 0.08–0.13 ms handoff overlap. A 378 ms activation stall namescpu-profile:start; a separate 102 ms stall with only 7.2 ms of measured work reportsunattributed. Verified the app and experiment toggle in a browser.