fix(perf): gateway startup benchmark reports n/a CPU/RSS on Windows#110253
fix(perf): gateway startup benchmark reports n/a CPU/RSS on Windows#110253paulcam206 wants to merge 1 commit into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 17, 2026, 9:56 PM ET / July 18, 2026, 01:56 UTC. Summary PR surface: Source +7, Tests +109, Other +57. Total +173 across 7 files. Reproducibility: yes. from source: current main explicitly returns Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Keep ready-anchored CPU reporting, but either preserve a bounded Windows peak-RSS measurement or expose the single Windows value as a distinct ready-time RSS metric; then provide a redacted Windows benchmark run proving the selected contract. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main explicitly returns Is this the best way to solve the issue? No. Ready-boundary CPU is a stronger solution to the earlier timing skew, but the Windows RSS change is not the best fix while it reports one post-startup snapshot as a maximum. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3d1b77103511. Label changesLabel justifications:
Evidence reviewedPR surface: Source +7, Tests +109, Other +57. Total +173 across 7 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (2 earlier review cycles) |
…up bench The gateway startup benchmark logged cpu/cpuCore/rss as n/a on Windows because readProcessRssMb and readProcessTreeCpuMs were Unix-only (ps). RSS: add a Windows implementation of readProcessRssMb via a CIM Win32_Process WorkingSetSize query (with pid validation); Unix ps path unchanged. CPU: measure it at the gateway's own ready boundary instead of via an external process query. The gateway already emits a memory.ready startup-trace snapshot; it now also reports process.cpuUsage() as cpuMs, and the bench reads memory.ready.cpuMs. This is exact and ready-anchored on every platform and retires the external ps/CIM CPU read from the startup bench, so post-ready work can no longer be charged to startup CPU. During startup the gateway is a single OS process (verified: no child processes at ready), so this equals the previous process-tree sum. readProcessTreeCpuMs stays for the Unix-only restart bench. Co-authored-by: Copilot <[email protected]> Copilot-Session: 8b7f11bb-0f17-4cd2-809d-a62dca26f62d
c7e971e to
b15c94e
Compare
What Problem This Solves
Fixes an issue where developers profiling OpenClaw on Windows would see
cpu=n/a cpuCore=n/a rss=n/ain the gateway startup benchmark (pnpm test:gateway:cpu-scenarios/scripts/bench-gateway-startup.ts). The CPU-per-core and RSS observations that the hot-CPU regression gate relies on were never captured on Windows, so the benchmark could not report — or gate on — startup CPU and memory there.Why This Change Was Made
scripts/lib/gateway-bench-probes.tsimplementedreadProcessRssMbandreadProcessTreeCpuMsonly for Unix (viaps) and returnednullonwin32.readProcessRssMbgains a Windows implementation via a CIMWin32_ProcessWorkingSetSizequery (with PID validation). The Unixpspath is unchanged.memory.readystartup-trace snapshot; it now also reportsprocess.cpuUsage()ascpuMs, and the bench readsmemory.ready.cpuMs. This is exact and ready-anchored on every platform and retires the externalps/CIM CPU read from the startup bench, so post-ready work can no longer be charged to startup CPU.readProcessTreeCpuMsstays for the Unix-only restart bench.This directly resolves the ClawSweeper/Codex review's [P1]: the earlier Windows approach read CPU via a synchronous CIM query that ran after
readyAt, so post-ready CPU could inflate the ratio and falsely trip the hot-CPU gate. Reading a child-reported value fixed at the ready instant removes that skew.Behavior notes:
memory.ready/memory.post-ready/restart.ready/ close startup-trace lines gain acpuMs=field on all platforms (one cheapprocess.cpuUsage()call; additive diagnostics only).process.cpuUsage()equals the previous process-tree sum — verified empirically (no child processes at ready). On Unix this also slightly improves accuracy (exact ready anchor; nopsfork per sample).User Impact
Developers and maintainers running the Windows gateway startup benchmark now get real
cpuMs,cpuCoreRatio, andmaxRssMbvalues instead ofn/a, and the CPU value is anchored to the ready boundary on every platform, so the hot-CPU regression gate is accurate. No product runtime behavior changes beyond the additivecpuMs=trace field.Evidence
AI-assisted; reviewers should inspect the code, tests, and CI. Highlights:
Before (Windows):
[gateway-startup-bench] default run 1/1: ... cpu=n/a cpuCore=n/a rss=n/aAfter — gateway emits ready-anchored CPU (Windows 11 build 26652, Node v24.18.0):
(~52.5 CPU-s over a ~55 s startup → cpuCoreRatio ≈ 0.95; no child processes at ready, so
process.cpuUsage()== the old process-tree sum.)test/scripts/gateway-bench-probes.test.ts(ps+ Windows CIM RSS, Unix CPU, null/failure paths) and acpuMsassertion insrc/gateway/restart-trace.test.ts:pnpm tsgo(core),pnpm tsgo:scripts,pnpm check:test-types,oxfmt --check,oxlint.autoreview(Codexgpt-5.6-sol, high) — clean ("patch is correct"): consistently replaces the external Windows CPU probe with a ready-anchored in-process metric, updates all call sites, and preserves Unix behavior.Note: As a fork PR, upstream CI may require maintainer approval to run.
Scope:
scripts/bench-gateway-startup.ts,scripts/lib/gateway-bench-probes.ts,src/gateway/restart-trace.ts(+ its test),src/gateway/server.impl.ts,src/gateway/server-close.ts, and the new probe test — +195/−22 across 7 files.Agent Transcript
Redacted agent transcript (GitHub Copilot CLI — trimmed to this fix)