Repository navigation
fix(gateway): keep chat request bursts responsive under load - #146102
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 12, 2026, 12:37 PM ET / 16:37 UTC (Revision 4). ClawSweeper reviewWhat this changesDisables Gateway WebSocket compression to improve request bursts under load, updates transport coverage and documentation, and reduces updater test process overhead. Merge readiness✅ Ready for maintainer review The fix remains necessary: current main and the latest release still negotiate compression. No actionable introduced defects were found, and the reported browser measurements support the change. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway receives WebSocket requests from browser and other clients, authenticates connections, and schedules their handlers. Compression processing happens before that scheduler, so decompression delays can stall otherwise inexpensive chat requests. flowchart LR
A[Browser and client requests] --> B[Gateway WebSocket transport]
B --> C[Uncompressed frame decoding]
C --> D[Authentication and payload limits]
D --> E[Bounded request scheduler]
E --> F[Chat and other handlers]
F --> G[Client replies]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -29, Tests -84, Docs -2. Total -115 across 10 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep request admission responsive through uncompressed transport while preserving scheduling fairness, authentication limits, and the documented larger-transfer tradeoff. Do we have a high-confidence way to reproduce the issue? Yes: compressed request bursts under event-loop load have a clear source-backed reproduction path, supported by reported Chrome and ws measurements; this review did not execute it. Is this the best way to solve the issue? Yes: disabling the optional extension removes the delay before scheduling at its owner, and the outbound threshold cannot prevent browsers from compressing tiny requests. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 78ca70be45ac. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
|
The updater fixture's matched heavy cases improved from 17.495 s to 4.457 s of test work. All 493 updater cases and 216 boundary/configuration tests pass. The native executor fixture now runs in the existing serial process lane. Production snapshot behavior, test assertions, and timeouts are unchanged. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…w#146102) * fix(gateway): keep chat request bursts responsive under load * test(cli): avoid repeated fixture snapshot process startup
…bursts (#173933) Re-enable permessage-deflate on Gateway sockets with no context takeover in either direction, and replace ws's streaming zlib path per connection with one inline zlib call per message. ws inflated every browser frame (browsers compress even tiny requests) through threadpool round trips and stopped parsing until each finished, so bursts serialized behind busy event-loop turns (#146102); outbound streaming deflate likewise cost a turn per 16 KiB and blocked the socket's send queue. Inline results return on nextTick (setImmediate for receivers that must yield), inflated size stays bounded by the receiver's live payload limit, and errors fall back to ws's own path for canonical close codes. Frames of 16 KiB and up are compressed at level 1; hello-ok, which carries device tokens, is sent uncompressed.
…bursts (openclaw#173933) Re-enable permessage-deflate on Gateway sockets with no context takeover in either direction, and replace ws's streaming zlib path per connection with one inline zlib call per message. ws inflated every browser frame (browsers compress even tiny requests) through threadpool round trips and stopped parsing until each finished, so bursts serialized behind busy event-loop turns (openclaw#146102); outbound streaming deflate likewise cost a turn per 16 KiB and blocked the socket's send queue. Inline results return on nextTick (setImmediate for receivers that must yield), inflated size stays bounded by the receiver's live payload limit, and errors fall back to ws's own path for canonical close codes. Frames of 16 KiB and up are compressed at level 1; hello-ok, which carries device tokens, is sent uncompressed.
Related: #136862
What Problem This Solves
Fixes an issue where opening a chat on a busy Gateway could take more than 30 seconds even though its session lookup and history handlers each needed less than 200 ms. Small requests sent together reached the handlers seconds apart.
Why This Change Was Made
Disable optional WebSocket compression. Browsers compress even tiny requests when
permessage-deflateis negotiated, andwsserially awaits asynchronous inflate callbacks before delivering each frame. Event-loop load multiplies that delay across the startup burst; the server's outbound compression threshold cannot prevent it. Uncompressed frames reach the existing bounded, fair request scheduler together.Remove the retired compression threshold and deflate-specific payload handoff. Preserve authenticated receiver limits, worker admission, and pre-auth/node control-frame yielding. Update the transport documentation.
CI follow-through also removes repeated snapshot-worker startup from the isolated updater test fixture. Only its explicitly initialized scratch databases use the real in-process snapshot primitive; other sources still use the actual worker. The native executor fixture moves to the existing serial process lane.
User Impact
Chat startup and other request bursts remain responsive under server load. Large histories and rosters use more bandwidth because frames are uncompressed. Clients already support the server declining this optional extension; no protocol version or configuration change is needed.
Evidence
Actual Chrome, ten tiny requests, synthetic 100 ms work per event-loop turn: compressed replies arrived at 401–3,104 ms; uncompressed replies all arrived at 106–118 ms. Verified Chrome set the compression bit on these small requests.
Independent 20-request
wsreproduction: compressed 300–6,008 ms versus all uncompressed replies at 100 ms.Live correlation: four requests sent together reached dispatch 1.65 s, 0.53 s, and 0.41 s apart, then completed in 98–110 ms each. This locates the delay before handler scheduling.
Extended the real Gateway burst regression to send compressed frames when negotiated, matching Chrome. It fails before the fix because only the first of 33 requests starts before the next immediate; all 33 start after the fix.
28 focused tests passed across request scheduling, large post-auth frame roundtrips, control/close frames, public worker ingress, and broadcast failure/backpressure recovery.
Independent review through P2: no actionable findings.
CI diagnosis: the original CLI lane spent 813.57 s running tests; its 493-case updater file accounted for 803.93 s. The same four heavy cases improved from 17.495 s to 4.457 s of test work with the fixture change (74.5%). Normal-wrapper wall time improved from 30.86 s to 23.50 s.
The full 493-case updater file passed after the repair, as did 216 tests across native executor, real worker snapshots, ledger cold reads, source/exclusion, and configuration ownership. The native executor’s nine cases run in the serial process lane; the formerly failing healthy-upgrade case passed in 2.191 s. One Linux-only POSIX-lock case remains covered by Linux CI.
The first CI attempt failed one existing native-executor readiness assertion; a diagnostic rerun made steady progress but its hosted fallback amplified the slow fixture cost. No test assertions or timeouts were relaxed.