Repository navigation
perf(gateway): shrink health and reconnect payloads - #178106
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. |
|
Negotiate compact passive health for updated operator clients and self-only hello presence for Control UI. Keep full health RPC diagnostics, profile bootstrap, roster delivery, and legacy payloads intact.
Use the protocol connect type for optional capabilities and mark the existing trusted health producer invariant for the assertion guard.
|
Codex review: needs maintainer review before merge. What this changesThis PR negotiates smaller passive health payloads and self-only Control UI hello presence while preserving legacy delivery and full diagnostic RPCs. Example: Forty signed web clients reconnect to a synthetic Gateway with 24 agents.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR provides a useful, maintainer-directed payload reduction with no actionable introduced defect found; failing exact-head CI still needs attribution before landing. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway health and handshake owners collect diagnostic and presence snapshots, project them for negotiated client capabilities, and deliver them over authenticated WebSockets to browser and native clients. flowchart LR
A[Health collector] --> B[Health cache]
B --> C[Capability projection]
D[Presence owner] --> E[Hello snapshot]
E --> C
C --> F[Authenticated WebSocket]
D --> F
F --> G[Browser and native clients]
Technical reviewBest possible solution: Retain the small shared projection and capability negotiation, then land once the exact-head CI failures are resolved or demonstrably attributed outside this patch. Do we have a high-confidence way to reproduce the issue? Current-main source sends the redundant diagnostic fields and hello roster; the submitted real-WebSocket measurements exercise that path, but this read-only review ran no target code. Is this the best way to solve the issue? The patch removes unused wire data at existing publication owners, shares one health projection, and preserves released-client contracts without adding another collector or cache. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f92e1a2e48e0. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +33, Tests +68, Docs +33, Other +294. Total +428 across 20 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 20, 2026, 1:55 AM ET / 05:55 UTC. |
08f2423 to
4403282
Compare
* perf(gateway): shrink health and reconnect payloads Negotiate compact passive health for updated operator clients and self-only hello presence for Control UI. Keep full health RPC diagnostics, profile bootstrap, roster delivery, and legacy payloads intact. * test(gateway): type negotiated hello fixtures Use the protocol connect type for optional capabilities and mark the existing trusted health producer invariant for the assertion guard.
What Problem This Solves
Health notifications and reconnect handshakes repeatedly transfer diagnostics and presence rows that updated clients can obtain on demand or already receive through the presence stream.
User Impact
Updated Control UI and native operator clients receive smaller health payloads. Control UI reconnects retain their own profile row in hello and receive the full roster through the existing presence stream. Older clients keep their existing payloads; full health diagnostics remain available through the
healthRPC. No configuration, database, or protocol-version migration is required.Why This Change Was Made
The Gateway now negotiates
health-summaryat the existing publication boundary, removing optional agent/heartbeat configuration and session activity from passive health and cached hello health. Control UI also negotiateshello-presence-self, removing the duplicate roster from hello while retaining the connecting client's profile bootstrap. The publication prepares each health representation once for interleaved compact and legacy recipients.The current hello contains a method/event capability list, not model catalogs or configuration schemas. Existing plugin catalog revisions remain unchanged. This change removes redundant payloads without adding persistent client caches or another invalidation lifecycle.
Evidence
Acceptance recorded before measurement: 24 synthetic agents and 40 signed clients, cold attach and warm reconnects reported separately, concurrent A/B pairs under an exclusive lock with two swapped 16-core allocations. The requested 60% health and 70% warm-hello reductions are targets; landing also requires reduced work without a material paired readiness regression. Readiness ends after hello plus initial presence.
The baseline discovery run completed against
b90b2cfb40ec77fde111297ee08d5617373282e0. Its warm hello was 39.9 KB: 24.2 KB of presence, 14.0 KB of method/event capabilities, and approximately 1.7 KB of other metadata. Health was 15.2 KB: 14.2 KB of agent details (including 8.8 KB of heartbeat configuration and 6.5 KB of repeated prompt text), 0.1 KB of top-level session diagnostics, and approximately 0.9 KB of remaining health. Field sizes overlap when reporting nested components. These are synthetic fixture measurements, not a capture of production payloads.Both concurrent browser pairs passed (CPU halves swapped for pair 2), with one cold attach and two warm reconnect waves per side per pair: 80 cold and 160 warm client attaches per side.
The health target is exceeded. The 70% warm-hello target is missed because the unchanged 14 KB method/event capability list is now the dominant floor; the measured reduction is 59.3%. Readiness is neutral within observed noise: individual warm p99 differences range from −6.4 to +11.0 ms, with no consistent directional regression after swapping CPUs. Cold hello p99 is 39,819 → 16,238 B; cold selected traffic is 2.75–2.76 → 1.71 MB. The native-profile pairs also passed (full hello presence retained):
All eight runs completed successfully, with 960 measured attaches total (320 cold and 640 warm). Every wave verified all 40 reconstructed rosters and health deliveries, with zero presence-recovery RPCs. CPU load was recorded with
mpstatfor context; setup used a separate CPU allocation before both sides moved to their measured 16-core allocations at the common start time. No production configuration or services were changed. The fixed workload verifies each client's own hello row, complete reconstructed presence againstsystem-presence, zero recovery RPCs, and changed health reaching every socket. Health changes use the real quarantine owner and public health collector after the first maintenance tick.Focused validation: 105 tests passed across the six affected Gateway/UI files; the subsequent broadcaster/closure run passed 50 tests across three files. Core typecheck (tsrs), changed-file lint/format, Swift formatting, and the export-name collision guard passed. The original health regression failed on the baseline and passes with the change. Native compilation/tests and broad validation are delegated to PR CI; no Testbox lease was used. Independent review completed cleanly on the final production and fixture diff (no actionable P0–P2 findings).
Reproduce either side with
node --import ./scripts/tsx.mjs scripts/perf/presence-churn-measure.ts --scenario payloads --clients 40 --agents 24 --rounds 2 --interval-ms 1000 --client-profile web --state-dir <new-synthetic-directory> --port <isolated-loopback-port> --start-at <shared-epoch-ms> --output <report.json>, adding--compact-payloadson B; repeat with--client-profile nativeand swap CPU halves.Limitations: cold attaches use new devices against an already-ready, health-prewarmed Gateway. Plugins/channels/cron/heartbeat execution are disabled; no production databases are copied. Reported traffic totals cover hello, health, and presence application JSON, excluding WebSocket/TCP framing, compression, unrelated RPCs, and browser rendering. The fixture does not reproduce the reported production 120–125 KB hello tail. Necessary runtime growth is limited to capability negotiation and one shared projection so the shipped legacy protocol remains intact; benchmark instrumentation accounts for most added lines.
Diff size: runtime implementation +28 lines; tests +76; reproducible benchmark +294; documentation +33. The requested non-test/non-doc path filter totals +346 because it also includes the benchmark, its README, and native/inline test edits. Runtime growth is the small negotiated compatibility boundary; no parallel diagnostic collector or persistent cache is introduced.
The first CI run caught an inferred fixture type that omitted optional connect capabilities and a missing
SAFETYmarker on an already-explained internal health assertion. The fixture now uses the realConnectParamscontract; all 44 focused hello tests passed again, and the single-file assertion scan matches the existing baseline. Both touched files passed focused lint/format, and the fixture repair received a clean independent review. The unrelated UI E2E type error was fixed upstream in #178096 and is incorporated through rebase. Runtime behavior still matches the measured implementation. Final-head CI: https://github.com/openclaw/openclaw/actions/runs/39377702149.