Repository navigation
fix(diagnostics): batch CPU profiles to avoid repeated startup stalls - #196422
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR adds bounded CPU-profile batches that share one profiler start and stop while preserving the existing empty-parameter behavior. Example: An operator needs twelve consecutive five-second CPU profiling windows on Node 24.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it adds useful, owner-approved batching that current main lacks, and source review found no discrete introduced correctness defect. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe administrator diagnostics RPC validates capture parameters, passes caller authority and cancellation to the shared profiling owner, and returns a bounded, sanitized in-memory profile. flowchart LR
A[Administrator RPC caller] --> B[Diagnostics parameter validator]
B --> C[Existing profile handler]
C --> D[Shared capture lifecycle]
D --> E[Runtime profiler]
E --> F[Sanitized profile and window boundaries]
F --> A
Technical reviewBest possible solution: Keep batching inside the existing capture owner, preserving empty-parameter behavior, native sample data, bounded responses, and caller-lifetime cleanup. Do we have a high-confidence way to reproduce the issue? Current main starts a separate capture for every empty-parameter request, so repeated profiler starts are source-verifiable; the Node 24 stall magnitude was not independently reproduced during this read-only review. Is this the best way to solve the issue? The smallest complete implementation extends the existing capture duration and returns boundaries over the unchanged sample timeline, avoiding duplicate graphs or another lifecycle owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 66c2b325e049. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +77, Tests +92, Docs +32, Other +318. Total +519 across 17 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 9, 2026, 10:56 PM ET / November 10, 2026, 03:56 UTC. |
|
Addressing the two evidence notes in the final-head review:
The reviewed head remains |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
What Problem This Solves
Repeated CPU profiling pauses a large Gateway once for every profile start, making consecutive production profiling windows expensive on Node 24.
User Impact
Operators can request
diagnostics.cpuProfilewith{ "windows": 12, "windowMs": 5000 }to collect a set with one profiler start and stop. Empty params keep the existing five-second behavior. The caller must allow the whole batch to finish; no profiler remains active between requests.Why This Change Was Made
The existing capture owner retains concurrency, cancellation, authority, redaction, and cleanup. A batch returns one standard profile plus
windowBoundariesMicros, preserving signed sample deltas without duplicating the call graph. Requests allow 1–30 windows of 100–5000 ms, at most 150 seconds requested. Oversized batch responses retain the existingprofile-too-largerefusal and never replace the timeline with a summary.Node 24 batches use the inspector's 10 ms interval because its native API ignores interval options. The first startup pause remains; subsequent windows need no restart. Node 26 keeps the shared native path. This is an additive RPC change with no protocol-version bump, config option, or database change.
Evidence
015b79a53f27566000a2b564294ca6650e6d4438.pnpm check:changedexposed dead-export failures in untouched modules, reproduced on exact parent1ebc46e1a52ff2b8828b6186e7b5ab943227c9ae. Source introductions/caller migrations are attributed; these are main regressions, not passing checks. The benchmark preload's typed-lint finding and protocol-registry export guard were corrected and their checks pass.Handwritten production growth is 45 lines; generated validators add 32 net lines with mechanical predicate renumbering. The additive caller contract accounts for the growth. Tests add 92 lines with a matching allocation. No capture manager, cache, or persistent sampler was added.
The synthetic fixture had 10,800 sessions, 4,300 settled runs, 40 plugins, five WebSocket clients and four mock-model warmup runs. Its agent DB was 268 MB on macOS arm64/APFS, not a 35 GiB/btrfs qualification. Absolute startup magnitude is therefore not a production claim. Empty-call baseline and batch use the same candidate dist. Whole-set CPU savings also include Node 24's native-versus-10 ms inspector sampling difference. Allocation volume was not measured; heap/RSS are retained-memory measurements. All source/runtime hashes stayed unchanged, and the isolated Gateway was shut down cleanly.
CI has two session-test failures outside this change. The fork authorization-code mismatch reproduces on exact CI main parent
a0ec2b5b4ba6532237705777a470a1d154cd1cccand traces to #194129 preserving valid sharing facts while its older test still expects generic invalidation. The visible-spawn failure also reproduces on that exact main parent and traces to #196206 routing repository URLs through managed worktrees while the old test still expects direct-project rejection. Security Review passed on this exact head.