Repository navigation
fix: high Gateway CPU while viewing diagnostics - #147110
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: needs maintainer review before merge. Reviewed September 13, 2026, 12:03 PM ET / 16:03 UTC (Revision 2). ClawSweeper reviewWhat this changesMoves diagnostic graphs onto lightweight Gateway resource reads, keeps full Debug snapshots refresh-driven, adds lifecycle regression coverage, and consolidates initial UI bundle partitions. Merge readiness✅ Ready for maintainer review This remains a useful, bounded fix: current main still repeatedly requests full diagnostics, and the related backend PR addresses complementary work. No blocking correctness or security defect was found. Priority: P2 Review scores
Verification
How this fits togetherThe Control UI requests diagnostics from the Gateway to populate activity graphs and operator snapshots. Resource polling now reads process counters without invoking the broader task and session status report. flowchart TD
A[Activity graphs] --> B[System information request]
B --> C[Process counters and cached disk readings]
C --> A
D[Open Debug or choose Refresh] --> E[Full diagnostic snapshots]
F[Debug timer] --> G[Live heartbeat and command lanes]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +10, Tests +281, Docs +2, Other +7. Total +300 across 23 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep resource observation lightweight while preserving explicit full diagnostics, live heartbeat and lanes, and connection-scoped cancellation. Do we have a high-confidence way to reproduce the issue? Yes for the polling mechanism: current main repeatedly invokes full status collection from diagnostics views. Production CPU impact was not reproduced in this read-only review. Is this the best way to solve the issue? Yes. Reusing system.info and one process-counter reader removes unnecessary work without weakening task integrity checks or creating another diagnostics API. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ca0746ad8c56. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
Merge the current CI baseline and use the shared startup grouping from #147110. Preserve immediate model invalidation for session events while the existing lazy client store qualifies command metadata changes. Ordinary messages skip the full metadata parser.
Bring in #147110 through normal main history and preserve the reviewed metadata source. Retain main's CI workflow fixture environment updates.
* fix: high Gateway CPU while viewing diagnostics * test: match agent selection observer contract * test: exercise diagnostics replacement through initial load
What Problem This Solves
Fixes high Gateway CPU and sluggish chat while the busyness overlay, Connection settings, or Debug page repeatedly requests a full status report.
User Impact
CPU, memory, and event-loop graphs keep updating through a lightweight resource read. Full Debug snapshots refresh on opening, connection or agent changes, and the existing Refresh action; lanes and heartbeat remain live. No database migration or integrity-policy change is required.
Why This Change Was Made
Every full status report performs task-table integrity checks, loads task and delivery records, and reconciles their state. Routine graph polling discarded that report. The graphs now consume the existing
system.inforequest, sharing the same process-counter reader asstatus. Connection settings uses one resource poll, and Debug no longer repeatedly collects full snapshots.The existing initial chunk grouping also consolidates startup partitions without pulling in deferred modules. Shared event-loop schemas retain their existing constraints, including integral channel sampling intervals.
The task integrity checks remain in place: they detect stale indexes that can hide records even when SQLite's quick check passes.
Evidence
The original polling regressions fail before the UI cutover: the overlay sends
status, Connection settings requests a separate report, and Debug repeats full snapshots during timer ticks. The focused backend, protocol, and UI tests pass. The existing browser E2E passes with live CPU/memory graphs updating while full-status request counts remain unchanged; refresh and reconnect retain their last-good/stale-response contracts. The production UI build passes its performance budgets, and independent P2 review is clean. Core, test, and UI type checks, scoped lint, formatting, unused-export checks, and the remaining protocol/architecture guards pass. CI exposed an adjacent provider-replacement fixture, now corrected through the real initial-load path. The combined source passes 102 focused tests. The build/schema follow-up passes 100 targeted checks, including five bundled Chromium flows; its exact-source comparison reduces startup requests from eight to seven and raw JavaScript by 748 bytes while preserving all 466 initial modules and every published budget.Live query attribution identified repeated complete task-table scans and integrity checks on the Gateway main thread. This follow-up will receive a separate deployment and live CPU/load comparison after landing.
Synthetic browser proof
Before: full snapshots were repeatedly refreshed in the background.
After: full snapshots use Refresh, while heartbeat and lanes stay live.
The overlay graphs continue updating through the lightweight resource request.