Repository navigation
perf(gateway): remove global async hooks from stall monitoring - #172531
Merged
Merged
Conversation
steipete
marked this pull request as ready for review
October 14, 2026 20:43
Contributor
|
ClawSweeper reviews are opt-in for maintainers. If a review is required, finish the work and validation first, then comment |
Contributor
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. |
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 15, 2026
…law#172531) * perf(gateway): remove global async hooks from stall monitoring * test(gateway): retire asynchronous stall capture expectation * test(gateway): feed native delay into HTTP health fixture
This was referenced Oct 16, 2026
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.
What Problem This Solves
Always-on stall attribution installs process-wide async hooks, allocating and timing every promise continuation even though this work serves only diagnostics.
User Impact
Reduces Gateway main-thread allocation. Explicit synchronous task labels, bounded stall warnings, event-loop health sampling, and the CPU flight recorder remain. Async continuations no longer inherit task labels. Accepted tradeoff: during healthy idle windows the native histogram is disabled, so an unscoped stall that finishes before the next sampling deadline can go unreported; explicit task stalls and overdue idle wakes remain observable. Documentation now states this limitation.
Why This Change Was Made
Remove the async hook and its AsyncLocalStorage/promise-finally bookkeeping. The existing event-loop sampler remains the owner of best-effort unscoped detection. Production code delta: -22 lines across the monitor and sampler.
Evidence
On an isolated Linux benchmark sandbox (Node 26.8.2), five rounds of 100,000 named async tasks, each with one awaited continuation:
Allocation sampling includes objects collected by major and minor GC (32 KiB interval). This isolates monitor overhead, not end-to-end Gateway RPC allocation; no production data or services were used. A follow-up real
sessions.listsidebar comparison used fresh synthetic fixtures with 5,000 sessions, 6,000 retained runs, 15,000 participants, 200 pending approvals, 100 cron jobs, and 12 projects; agent DB 235,978,752 bytes. Five rounds of 1,000 requests for 200 sidebar rows, one client: median allocation 2.8324 → 2.8153 MB/RPC; main-thread CPU 3.4653 → 3.4427 ms/RPC; wall time 3.9488 → 3.8148 ms/RPC; GC 0.1454 → 0.1392 ms/RPC. This is an effectively neutral end-to-end result, not the large isolated-workload gain. An initial 100-request pilot had higher head CPU; the longer matching comparison did not reproduce that regression. This fixture matches metadata counts, not production database/page-cache pressure.Both production variants built successfully using
pnpm build:runtimein the sandbox. Benchmark source at 08a98eb is production-identical to the subsequent test-only correction.Focused local proof:
node scripts/run-vitest.mjs src/infra/main-thread-stall.test.ts src/gateway/server/event-loop-health.test.ts --maxWorkers=1passed 26 tests in 28.91 s including cold compiler preparation (test bodies approximately 0.13 s). Changed-file oxfmt, focused repository lint, and diff whitespace checks passed. Broad validation belongs to PR CI; no Testbox/Crabbox lease used. An initial ordinary lint invocation entered artifact preparation and was stopped; the supported focused lint path passed.Independent subagent review (autoreview route unavailable): no remaining actionable P2+ findings. Reviewer identified the idle detection gap; it is explicitly accepted and documented above.
CI follow-up: the first run failed
src/gateway/server-channels.test.tsbecause it still expected the retired global async hook to record a later callback. The correction removes that obsolete observation and Bun-only skip while preserving the startup/logging assertions. That single file passed all 91 tests locally (36.59 s wrapper, 33.14 s Vitest including cold compilation), with focused lint/format and independent review clean. No CI rerun was dispatched; the corrective commit receives normal PR CI.A second CI run exposed the same retired-hook assumption in
src/gateway/server-http.event-loop-health.test.ts. Its synthetic clock jump now supplies native histogram delay, preserving the actual HTTP readiness flow and the assertion that repeated readiness reads do not consume a pending sample. The obsolete async-task warning assertion and Bun-only skip were removed. The single test passed locally (12.60 s wrapper, 213 ms test body); focused lint/format and independent review passed. Production code and benchmark results are unchanged.