Skip to content

test(perf): measure RPC allocation promotion and reconnect recovery - #178075

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-micro-stress-rpc-allocation-and-latency-20260919
Oct 20, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-micro-stress-rpc-allocation-and-latency-20260919

Conversation

@steipete

@steipete steipete commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Gateway allocation comparisons currently report sampled bytes and total GC without promoted bytes or a major/minor split. That can make a change look cheaper while it creates more old-generation garbage. The existing RPC driver also cannot isolate describe and reconnect costs.

User Impact

No production behavior changes. Maintainers can compare allocation, promotion, GC, transport latency, and response bytes together before choosing a performance fix.

Why This Change Was Made

Extend the existing benchmark owners instead of adding another stress framework. The shared profiler identifies the main isolate before Gateway startup and bounds each capture with synchronous trace markers; worker collections and profiler setup/teardown are excluded from promotion. Existing history/diff workloads gain opt-in allocation capture. The transcript driver gains bounded RPC concurrency, describe, connect, and staggered reconnect scenarios with sidebar recovery checks.

This is the measurement stage of the RPC performance work. Production runtime LOC delta is zero; benchmark/test growth supplies missing measurements and response checks. There is no performance-improvement claim in this change.

Evidence

Focused profile/diagnostics tests pass. The profile test exercises real V8 allocation/GC traces and rejects worker, foreign-process, out-of-window, malformed, and incomplete accounting. Changed-file formatting/lint, export collision guard, and both required import-closure test files pass (22 closure tests). Independent review identified missing child-membership, hello-payload, and message-subscription acknowledgment assertions; all were strengthened. The final independent review is clean at P0–P2.

Runtime build and independent 5,000-session / 6,000-run fixture generation passed on the authorized sandbox. All seven scenarios completed through real loopback Gateways on runtime base de3473171a22ad4c062f65f4b1ff3dccf462419f, using concurrent paired runs and swapped 16-core halves. No Testbox/Crabbox lease was allocated.

Baseline medians across four samples (decimal units; this PR does not claim a before/after speedup):

Scenario Allocated MB/op Promoted KB/op Major GC ms/op Minor GC ms/op
sessions.list 1.3534 45.27 0.0101 0.1053
sessions.describe 0.1735 17.02 0 0.0270
connect 0.4697 25.79 0 0.2415
reconnect recovery 5.8814 336.89 0 0.8040
chat.history (default) 0.5736 34.37 0.0172 0.0664
sessions.diff (all/full) 0.9812 25.99 0 0.0617
transcript broadcast, per turn 165.5544 14893.44 4.8316 13.8606

List p99 was 34–48 ms at concurrency 8 (100 sidebar rows, 99,257 response bytes/call); describe 5.3–6.4 ms; history 88–120 ms and diff 46–52 ms at concurrency 40. Forty reconnecting clients recovered their sidebars in about 4,892 ms with starts spread over about 4,873 ms. Connect handshake p99 varied from 63–299 ms. These are protocol clients, not rendered UI/native-app measurements. Pure RPC scenarios have no background traffic; the broadcast scenario includes list polling. Broadcast-normalized costs describe the whole measured workload, not isolated encode/send cost.

The first CI run found unchecked client indexing in the new harness. Bounded scheduling now consumes actual client objects through a shared iterator; the targeted pnpm tsgo:scripts lane passes. A live run also exposed malformed worker-startup trace lines outside the capture; those are now excluded before parsing, while malformed captured main-isolate data remains an error. The revised profile tests pass (9/9), changed-file format/lint pass, and the repair received another clean independent review. PR CI supplies the broad gates.

Measurement contract: 5,000 sessions / 6,000 retained runs, 40 operator sockets; matched request shapes and completed-operation denominators. A/B comparisons run concurrently on separate 16-core halves under the measurement lock, swapping halves on the next pair. Compare paired differences, sampled bytes, promoted bytes, major/minor GC, RPC p50/p99, CPU, and event-loop delay together. A lower byte sample with worse GC is not a win. The initial 64 MiB transcript fixture preserves roster/run shape but does not reproduce multi-GB page-cache pressure.

Exact-head CI and inherited failure

On head a942f0e9c2ce6e69b63ffcf693700a3a182f3fcc, CI run 39375437350 passed the changed tests, scripts typecheck, production types, lint, guards, and other selected jobs. The sole non-aggregate failure is check-test-types-core-1: ui/src/e2e/session-scoped-delivery.e2e.test.ts:103, TS2367 ("preview-on" | "roster" compared with "preview-off"). The CI gate consequently remains red.

This unchanged main-file error was introduced by #178074, after the scheduled main run used by automatic classification. Its blob is identical in the PR and base d97b12486899e964e39593db8055682010f5bd83: f9099f96aea18071dbf00f1ebb7e627c48e338e9. Compiling an unmodified copy of that base file in the sandbox, with a temporary config extending test/tsconfig/tsconfig.core.test.ui-e2e.json and selecting only that file, reproduced exactly TS2367 at line 103 (exit 2). Existing sandbox dependencies/import closure were used; this was a single-file attribution check, not another broad CI run. No production or UI source is changed by this PR. Landing uses the authorized inherited-failure exception; the failure is not reported as green.

@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T05:35:51.851783Z a942f0e New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: L labels Oct 20, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 20, 2026
@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR adds GC promotion accounting, history/diff allocation capture, and describe/connect/reconnect benchmark scenarios.

Example: Forty clients reconnect with starts staggered by 125 ms.

  • Before: The driver cannot measure reconnect recovery separately.
  • After: The driver validates replacement handshakes, restores subscriptions, checks sidebar identities and timestamps, and reports recovery and allocation costs.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, coherent benchmark extensions with recorded end-to-end measurements, distinct accounting tests, and the previous finding resolved.
Proof confidence 🐚 platinum hermit (4/6) The ordinary contributor-proof gate does not apply to this maintainer-authored PR; its body nevertheless records real loopback-Gateway allocation and recovery results for the changed drivers, with protocol-client and fixture limitations stated.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Maintainers cannot compare promoted bytes and major/minor GC alongside allocation costs or isolate describe and reconnect recovery costs.
Reason: The maintainer-authored direction supplies useful measurements through existing tooling and explicitly avoids claiming a runtime performance improvement.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it adds useful measurement capabilities, and the prior type-safety finding is resolved; no new actionable code defect was found.

Priority: P2
Reviewed head: a942f0e9c2ce6e69b63ffcf693700a3a182f3fcc

Before merge

None.

Findings

None.

Agent review details

How this fits together

Repository benchmark drivers send synthetic WebSocket workloads to an isolated Gateway and combine responses, private profiler IPC, and GC traces into measurement reports.

flowchart LR
  Fixture[Synthetic fixture] --> Driver[Benchmark driver]
  Driver --> Gateway[Isolated Gateway]
  Driver --> Profiler[Profiler preload]
  Gateway --> Responses[WebSocket responses]
  Profiler --> Traces[Profiles and GC traces]
  Responses --> Report[Measurement report]
  Traces --> Report
Loading

Technical review

Best possible solution:

Retain the shared profiler and existing benchmark drivers as the owners of the added measurements and response validation.

Do we have a high-confidence way to reproduce the issue?

This is a benchmark capability addition; source inspection confirms the missing measurements on current main, and no target code was executed during this read-only review.

Is this the best way to solve the issue?

Extending the existing profiler and workload drivers is appropriate: isolate identification, capture markers, bounded concurrency, and reconnect assertions serve distinct measurement requirements without introducing another framework.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against eb54f49633be.

Provenance checked

  • Shared allocation profiling and GC diagnostics keeps the original intent (778a1b7: Measure allocation churn per completed operation while separating retained-memory context and keeping instrumentation opt-in.)
  • Transcript workload execution keeps the original intent (838360f: Provide repeatable synthetic Gateway workloads with verified completion and subscriber delivery.)
  • History/diff profiling keeps the original intent (5387b20: Attribute full-RPC costs using matched request shapes, synchronized workloads, and response checks.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit f21cc67 adds scripts/lib/gateway-bench-profile-preload.ts:2 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f21cc6720c5c; files: scripts/lib/gateway-bench-profile-preload.ts)
  • Vincent Koc: Raw commit eb32f22 adds scripts/lib/gateway-bench-profile-preload.ts:3 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: eb32f229ef60; files: scripts/lib/gateway-bench-profile-preload.ts)

PR surface

Tests +73, Docs +37, Other +470. Total +580 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 77 4 +73
Docs 1 39 2 +37
Config 0 0 0 0
Generated 0 0 0 0
Other 5 647 177 +470
Total 7 763 183 +580

Review metrics

Metric Value Why it matters
New benchmark controls 3 CLI controls Adds history/diff --allocations and transcript --rpc-concurrency and --reconnect-stagger-ms without adding product configuration.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Useful internal measurement tooling with no production-runtime behavior change or demonstrated urgent user regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-20T05:19:53.688Z sha cc9d68f4adaf1b1a4a7af33c34a7723f1d512c47 :: needs changes before merge. :: [P2] Narrow indexed clients and reconnect timestamps before using them

Reviewed October 20, 2026, 1:39 AM ET / 05:39 UTC (Revision 2).

@steipete
steipete force-pushed the steipete/perf-micro-stress-rpc-allocation-and-latency-20260919 branch from cc9d68f to a942f0e Compare October 20, 2026 05:32
@steipete

Copy link
Copy Markdown
Contributor Author

Addressed the indexed-client finding with bounded iteration over actual clients and a max/min reconnect-start calculation. The targeted scripts typecheck now passes. The PR body also records completed live runs of all seven scenarios, including describe/connect/reconnect, and their allocation/promotion/GC results and limitations.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 20, 2026
@steipete
steipete merged commit f5b87c5 into main Oct 20, 2026
117 of 120 checks passed
@steipete
steipete deleted the steipete/perf-micro-stress-rpc-allocation-and-latency-20260919 branch October 20, 2026 05:46
@steipete

Copy link
Copy Markdown
Contributor Author

Merged at f5b87c5 using the authorized inherited-failure exception. Exact-head run 39375437350 passed all selected jobs except core test-types and its aggregate gate. The sole diagnostic is TS2367 in ui/src/e2e/session-scoped-delivery.e2e.test.ts:103, introduced by #178074. The file has identical blob f9099f96aea18071dbf00f1ebb7e627c48e338e9 in the PR and its main base, and an unchanged base-file compile reproduced that exact diagnostic in the sandbox. Details and limitations are in the PR body; CI is not being described as green.

Focused profile/diagnostics tests, closure guards, scripts typecheck, changed-file format/lint, independent review, and real synthetic-Gateway runs of all seven scenarios passed. This lands the measurement infrastructure; no runtime performance improvement is claimed yet.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
…penclaw#178075)

* test(perf): measure RPC allocation promotion and reconnect recovery

* fix(perf): isolate captured GC traces and bound RPC clients
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant