Repository navigation
perf(runtime): stop GC telemetry from waking idle workers - #173574
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 SummaryThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f9fb71bc65
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Companion containment is in #173577. It leaves The two PRs have no overlapping files. Your one-second sampler preserves the detector input this safety net needs; no observer implementation is duplicated. Synthetic detector/transport and lifecycle regressions pass (23 tests), with four expected failures against the original implementation. Neither PR claims a reproduced native crash or measured elimination of the production storm. |
|
Codex review: needs changes before merge. What this changesThis PR replaces per-collection GC callbacks with a shared native profiler sampled once per second. Example: A Node Code Mode worker finishes 16 allocating cells and then remains idle.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep open: this PR provides useful maintainer-directed performance work absent from main, with one test-lane defect to repair. Priority: P2 Before merge
Findings
Agent review detailsHow this fits togetherThe isolate-local sampler supplies GC counts and durations to the Code Mode pressure guard and diagnostics publishers, which forward worker samples through existing memory ports to metric exporters. flowchart LR
A[Native V8 collections] --> B[Shared GC profiler]
B --> C[One second sampler]
C --> D[Code Mode pressure guard]
C --> E[Diagnostics publisher]
E --> F[Worker memory port]
F --> G[Metric exporters]
Technical reviewBest possible solution: Retain the shared sampler and move the native one-minute regression into a separately registered release-only test file. Do we have a high-confidence way to reproduce the issue? Current-main source schedules per-GC JavaScript callbacks, and the supplied real-worker probe reports their removal after replacement; the reported high-frequency production storm remains unreproduced, and this review executed no target code. Is this the best way to solve the issue? Sharing a native sampler at the existing observation boundary addresses per-GC wakeups across consumers; the documented reason-label tradeoff is intentional and the long regression needs different test routing. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 086fc5ca52d2. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource +7, Tests +69, Docs +7. Total +83 across 8 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
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 October 15, 2026, 8:17 PM ET / October 16, 2026, 00:17 UTC. |
|
Landing under the operator-authorized inherited-failure exception for exact head CI attempt 1 has one root failure: The exact unchanged main parent Node 24.19.0, unprivileged isolated Linux replay, single failing test file: matching failure took 67.20 s on main parent and 60.30 s on tested merge (CI: 84.78 s). Full repetition outcomes and commands are in the PR body; this is not a claim that CI or all replays passed. No CI rerun. The relevant fixture, adapter, pairing checks, and skill-discovery source blobs are identical across the tested merge boundary. Independent review is clean; the real-minute test-cost finding was explicitly considered and answered. Using the operator's exact-head REST fallback because the native merge wrapper provisions a separate canonical PR worktree outside this fixed lane. Production was not modified. |
The GC profiler fixture introduced in 9a8ef35 (#173574) added an unbound-method suppression that failed the main suppression ratchet. Give the captured native stop function its explicit GCProfiler receiver contract, retaining stop.call(this) and the zero-duration GC pressure probe. The suppression allowlist and every existing assertion remain unchanged. No production runtime or update behavior changes. Node 24 focused proof: watchdog 3 passed / 1 existing Linux-only skip (131.18s file time including compiler preparation and the real idle interval); explicit executor consumer 15 passed (pnpm test src/agents/code-mode-node.test.ts --maxWorkers=1, 83.57s command wall). The combined selector omitted the executor, so it was run explicitly. Owning agents-tools types, type-aware/boundary lint, format, and independent P2 review passed. Suppression ratchet: before 1 failed / 2 passed (12.84s command wall), with this entry and the independent warm-reload probe entry; after, only scripts/lib/control-ui-warm-reload-probe.ts remains. No allowlist extension. check-changed passed its other static gates but exposed unrelated UI render types and unused exports. Main's 56c3151 fixes render; its failed UI type graph passed after fast-forward integration. Knip's unrelated unused exports remain recorded in the lane evidence. No workflow reruns or extra pushes for green.
The GC profiler fixture introduced in 4f0ce6b (openclaw#173574) added an unbound-method suppression that failed the main suppression ratchet. Give the captured native stop function its explicit GCProfiler receiver contract, retaining stop.call(this) and the zero-duration GC pressure probe. The suppression allowlist and every existing assertion remain unchanged. No production runtime or update behavior changes. Node 24 focused proof: watchdog 3 passed / 1 existing Linux-only skip (131.18s file time including compiler preparation and the real idle interval); explicit executor consumer 15 passed (pnpm test src/agents/code-mode-node.test.ts --maxWorkers=1, 83.57s command wall). The combined selector omitted the executor, so it was run explicitly. Owning agents-tools types, type-aware/boundary lint, format, and independent P2 review passed. Suppression ratchet: before 1 failed / 2 passed (12.84s command wall), with this entry and the independent warm-reload probe entry; after, only scripts/lib/control-ui-warm-reload-probe.ts remains. No allowlist extension. check-changed passed its other static gates but exposed unrelated UI render types and unused exports. Main's a11e38b fixes render; its failed UI type graph passed after fast-forward integration. Knip's unrelated unused exports remain recorded in the lane evidence. No workflow reruns or extra pushes for green.
What Problem This Solves
Prevents GC telemetry from scheduling event-loop work after every collection in idle Code Mode workers, other instrumented workers, and the main isolate. Related: #173306.
User Impact
Collection counts, kinds, elapsed durations, worker attribution, storm warnings, and the near-limit Code Mode thrash guard remain available. Native GC samples now use
reason="other"because the native profiler does not expose callback flags; SDK-provided bounded reason labels remain supported. No configuration, schema, or deployment change.Why This Change Was Made
Replace per-GC
PerformanceObserverinstances with one sharedv8.GCProfilerper isolate, drained by an unreferenced one-second timer. Code Mode protection and exporter demand subscribe to the same sampler. The last subscriber drains and stops it; new subscribers do not receive earlier collections. Worker metrics retain their existing memory-port batching.This removes the per-collection native/JavaScript immediate queue and duplicate Code Mode observers. Production delta: +7 lines; sharing sampler ownership and its stop/drain lifecycle is necessary to preserve continuous actual GC counts and durations. Heap size and ELU alone cannot supply those counters. Native profiling does record heap statistics internally, and Node releases stopped native profiler callbacks on subsequent GC rather than immediately; workload measurements below cover that tradeoff.
Evidence
Isolated Linux, Node 26.8.2, synthetic real Code Mode worker with 16 completed cells and metrics enabled; no production mutation. Before/after:
Gap: the reported ~100 majors/second production storm did not reproduce in this sandbox. Idle collection frequency is neutral; this proves removal of the event-loop feedback mechanism, not a measured production storm reduction. The regression fails on the original observer because it schedules Immediate work, passes after replacement, and also enforces fewer than 10 majors over a real minute. That one-minute test is intentional: fake timers cannot exercise native idle GC scheduling.
Node's stock platform disables V8 idle tasks;
schedule_idleis a callback flag, not evidence that worker idle deadlines execute immediately. Source inspection: Node platform, GC observer delivery, native GC profiler.Focused local proof only (one worker):
diagnostic-gc.test.ts6 passed / 7.82 s;code-mode-node.gc.test.ts1 passed / 3.30 s; Nodecode-mode-node.test.ts15 passed / 16.44 s, including zero-duration near-limit retirement/recovery; Nodecode-mode-node.watchdog.test.ts3 passed, 1 Linux-only test skipped / 84.90 s including compiler-cache preparation and the real 60-second idle interval. Changed-file oxfmt, scoped repository oxlint, andgit diff --checkpass. Broad build/typecheck/suites belong to PR CI; no Testbox/Crabbox lease used.Simplification pass completed. Independent subagent review (autoreview route unavailable): clean, no actionable P0/P1/P2 findings. The configured autoreview provider selector was refused before launch; operator configuration was not changed.
CI and inherited failure attribution
Exact head
f9fb71bc659d32452ac711fc387ad56bf6dbee2c, CI attempt 1: all selected checks passed exceptchecks-node-changed-14and its downstreamopenclaw/ci-gate. The sole failed file wastest/e2e/qa-lab/runtime/required-native-same-session.e2e.test.ts, casesettles required native empty workspaces and same-session follow-ups through public RPC. Security, production/test types, scoped lint, docs, other Node shards, and UI checks passed. No CI rerun.Replayed only that file using Node 24.19.0, private-QA runtime build preparation, unprivileged processes, two CPU cores per run, synthetic state, and isolated loopback network namespaces. Exact CI main parent:
012bb1ccaf0b63696b2608599b1cf4ea869a4245. Exact tested merge:0dde71949ebe75efd257f2596943394f63d42943; verified ordered parents and merge tree.implicit-main after-agent-wait run failed before settlementagent.waiterror forREQUIRED-NATIVE-0-AWorkspaceAccessUnavailableError: Remote workspace skill discovery failedThe tested merge passed once and reproduced the exact failure on its second run. The unchanged main parent passed runs 1, 3, and 4; run 2 exposed a separate live-dispatch-owner failure; run 5 reproduced the exact CI failure above. These are inherited failures, not five clean replays. Earlier root-owned sandbox attempts were invalid for this fixture because workspace quiescence rejects root-owned worker sessions; they are excluded from attribution.
Command:
OPENCLAW_E2E_USE_PREBUILT_DIST=1 OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs test/e2e/qa-lab/runtime/required-native-same-session.e2e.test.ts --maxWorkers=1. Required build preparation:OPENCLAW_BUILD_PRIVATE_QA=1 node --import ./scripts/tsx.mjs scripts/build-all.mts qaRuntime(both pinned revisions passed).The failing test, remote-workspace adapter, pairing checks, and skill-discovery owner are unchanged between the main parent and tested merge. Its fixture has no GC exporter subscription, and the failure precedes native inference/Code Mode execution. Landing under the explicitly authorized inherited-failure exception; the failed CI run remains red. Follow-up: stabilize native workspace skill discovery during startup; the separate baseline dispatch-owner failure also needs attention.
The automated review's test-cost finding was considered and declined with a recorded reply: the requested real 60-second idle regression intentionally remains in PR coverage because fake clocks cannot exercise native V8 idle GC scheduling.