Skip to content

test(gateway): measure populated startup through usable session access - #178087

Merged
steipete merged 4 commits into
mainfrom
steipete/perf-micro-boot-critical-path-20260919
Oct 20, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/perf-micro-boot-critical-path-20260919

Conversation

@steipete

@steipete steipete commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Gateway startup measurements could stop at HTTP readiness without proving access to the populated session roster. They also accepted a process killed by the benchmark's two-second teardown timeout. That makes startup optimizations difficult to assess against both usable readiness and lifecycle behavior.

User Impact

Developers can measure startup through access to a populated session roster and detect unclean benchmark shutdowns. There is no change to Gateway readiness or cache behavior.

Why This Change Was Made

Add an opt-in teamBoot workload with 44 synthetic startup-active external plugins, eight agents, 4,096 sessions, a 135,950,336-byte state database, and eight 1,228,800-byte agent databases. Prepared fixture roots and a shared future start time support concurrent paired runs without measuring fixture generation.

Measure the first successful sessions.list over the real WebSocket transport. The populated case must return the exact seeded session; refused connections, empty rosters, and unrelated sessions do not count. Preserve all startup trace lines and expose the already-parallel catalog-snapshot and model-runtime bootstrap steps. Benchmark ports are at least 40000. Hosts unable to supply that range fail with a bounded, explicit setup error.

Record shutdown duration and forced cleanup. The populated case allows 30 seconds for teardown and fails on nonzero exit, signal termination, or forced cleanup. Other workloads retain their existing teardown policy.

This final change does not alter Gateway cache policy, readiness, plugin activation, or recovery ordering. Runtime production changes are eight added and two removed lines of trace instrumentation (net +6); the remaining growth is the requested benchmark, fixture, documentation, and regression coverage.

Measurement and Decision

A read-only main-thread compile-cache experiment was rejected and removed: it did not meet the pre-recorded >5% startup improvement threshold. The benchmark and tracing remain as the requested measurement infrastructure; no startup speedup is claimed for this final PR.

The experiment compared baseline de3473171a22ad4c062f65f4b1ff3dccf462419f plus identical trace instrumentation against the cache candidate on Node 26.8.2. Four concurrent pairs ran per condition under one exclusive measurement lock at a time, with separate state/cache roots, synchronized starts, 16 CPUs per side, and alternating CPU halves. The remaining short pairs were batched under one lock acquisition. Cold bytecode and explicitly prewarmed bytecode were measured separately. The decision uses within-pair candidate-minus-baseline differences.

Bytecode condition Baseline RPC median Candidate RPC median Median paired RPC delta Median paired change Median paired readyz change
Cold 13,390.34 ms 13,351.67 ms -47.05 ms -0.36% -0.34%
Prewarmed 13,074.09 ms 12,881.58 ms -252.35 ms -1.93% -1.99%

Cold paired RPC changes were +0.01%, +0.14%, -0.72%, and -0.78%; prewarmed changes were -4.89%, -1.19%, -1.75%, and -2.11%. With only four samples, nearest-rank p95 is the maximum: cold 17,816.33 → 17,818.01 ms; prewarmed 15,456.12 → 14,699.62 ms. Median process-tree CPU was 22.0 → 22.5 seconds cold and 22.0 → 22.0 seconds prewarmed (individual readings have whole-second granularity). Median peak RSS moved from about 4,235 → 4,126 MiB cold and 4,247 → 4,155 MiB prewarmed. Per-pair mpstat records were retained; mean idle across the measured CPU set ranged from 72.5–93.4% cold and 88.5–93.5% prewarmed, including the benchmark itself.

The first cold baseline sample's critical path was bootstrap 0–3.00 s, HTTP listening around 5.71 s, session projection complete around 6.41 s, post-bind plugin startup 6.73–16.41 s, and final sidecar readiness at 17.68 s. The 44 external fixture plugins spent 8.86 s preparing sources serially. That phase awaits isolated worker preparation; catalog and model-runtime bootstrap work already overlap. Main-session recovery overlaps projection before readiness; subagent recovery is already after readiness.

The fixture establishes a repeatable populated workload, not the external/bundled plugin mix or remote-worker topology of any production deployment. The <8-second target was not reached. The experiment used prior-base artifacts and was rejected; its numbers are not an exact-head performance claim. Broader plugin-preparation concurrency needs a separate change that preserves ordered selection, registration, rollback, and memory-plugin ownership.

Evidence

  • Focused benchmark tests: 28/28 pass, including a low-port allocator that previously retried indefinitely. The socket fixture proves refusal → empty roster → unrelated roster → seeded session, plus clean exit versus exit 23. Before the shutdown fix, the exit-23 case incorrectly returned benchmark success; the regression failed on that behavior.
  • All 16 real Gateway experiment samples served the seeded session. Both first cold samples exceeded the old two-second teardown grace; the other 14 exited cleanly. Those first cold samples are startup evidence only.
  • Updated-harness real Gateway functional check passed: readyz 200, seeded session RPC served, exit 0, no signal, no forced cleanup. This used the unchanged baseline artifact; timing is not used for a performance comparison. After CI identified a raw fixture write, a fresh fixture generated through the existing async machine-state writer retained the same database sizes and also passed this Gateway check. The targeted writer-boundary check failed before that repair and passed afterward.
  • Changed-file formatting and lint pass. The allowed targeted pnpm tsgo:core check passed using tsrs before the benchmark-only teardown follow-up.
  • Independent Codex reviews of the final instrumentation and subsequent repairs found no actionable P0–P2 issues.
  • No new module or test file, dependency, configuration option, or schema change. No Testbox lease or local build/full suite. PR CI supplies broad validation. The first run caught the fixture writer violation described above. All selected checks passed on repaired head d98c789a94cd6362b848d72a5e20ac3396e6352d, including the database-writer guard, Node tests, types, lint, and all three PostgreSQL conformance shards: CI run 39382826822. The required CI and security gates are green; fresh ClawSweeper and Codex reviews report no outstanding findings.

@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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts size: L labels Oct 20, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro 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: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro 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 a populated startup workload, measures successful session access, records shutdown outcomes, and traces two existing bootstrap steps.

Example: The populated workload serves agent:incident-agent-01:bench-0, then exits with code 23 during teardown.

  • Before: The benchmark could accept a nonzero exit occurring during teardown.
  • After: The benchmark reports an unclean shutdown and exits unsuccessfully.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, focused measurement infrastructure with recorded real-Gateway functional evidence and meaningful CLI regressions; required CI is still pending.
Proof confidence 🐚 platinum hermit (4/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its recorded functional run exercises the updated benchmark against a real Gateway, verifies the seeded session, and observes clean shutdown, without claiming exact-head performance gains.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Developers could accept startup measurements without usable populated-session access or clean benchmark shutdown.
Reason: The maintainer-authored direction addresses concrete measurement blind spots, preserves runtime policy, and withdraws an optimization that missed its acceptance threshold.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR adds useful startup measurement coverage, and no actionable introduced defect was found.

Priority: P2
Reviewed head: d98c789a94cd6362b848d72a5e20ac3396e6352d

Before merge

None.

Findings

None.

Agent review details

How this fits together

The startup benchmark creates isolated synthetic state, launches a Gateway, probes HTTP and WebSocket access, and produces timing and lifecycle results.

flowchart LR
  A[Benchmark options] --> B[Synthetic fixture]
  B --> C[Gateway child process]
  C --> D[HTTP readiness probes]
  C --> E[Session RPC probe]
  C --> F[Process tree shutdown]
  D --> G[Benchmark report]
  E --> G
  F --> G
Loading

Technical review

Best possible solution:

Retain the populated benchmark and existing lifecycle owners, then land after the exact-head required checks pass.

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

Current main finishes HTTP probing without requiring session RPC success and does not reject teardown-time failures; source inspection establishes both measurement gaps without executing target code.

Is this the best way to solve the issue?

The change extends the existing benchmark, WebSocket client, state writers, and process cleanup owner, providing a focused solution without retaining the rejected cache optimization.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Parallel catalog and model-runtime bootstrap keeps the original intent (55c8adc: Overlap independent preparation while joining both operations before bootstrap owns resources.)
  • Bounded benchmark teardown keeps the original intent (1baab3b: Prevent indefinite teardown waits by retaining bounded graceful and forced process cleanup.)
  • Prepared fixtures and high-port selection changes intended behavior with a stated reason (4645923: Measure recovery with prepared isolated state and high listener ports outside fixture generation.)
  • HTTP-only startup completion changes intended behavior with a stated reason (unknown: Existing code measures readiness and process metrics; scoped history did not establish a distinct rationale for excluding session-access verification.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 4645923 adds scripts/bench-gateway-startup.ts:1010 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4645923ce333; files: scripts/bench-gateway-startup.ts)
  • Vincent Koc: Raw commit 1fe2c48 adds scripts/bench-gateway-startup.ts:405 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1fe2c4844059; files: scripts/bench-gateway-startup.ts)
  • Galin Iliev: Raw commit 14e26a3 adds scripts/bench-gateway-startup.ts:799 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 14e26a380d34; files: scripts/bench-gateway-startup.ts)

PR surface

Source +6, Tests +177, Docs +48, Other +283. Total +514 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 8 2 +6
Tests 1 180 3 +177
Docs 1 48 0 +48
Config 0 0 0 0
Generated 0 0 0 0
Other 1 300 17 +283
Total 4 536 22 +514

Review metrics

Metric Value Why it matters
Implementation versus test LOC Implementation +308/-19; tests +180/-3 Growth adds the requested fixture and measurement behavior within existing modules; runtime instrumentation accounts for only +8/-2.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦪 silver shellfish.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: Useful developer measurement infrastructure with limited impact on ordinary Gateway users.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦪 silver shellfish.
  • 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:28:36.040Z sha 36df3f07cdddd2d80f57440dc2882960402a8d0d :: needs maintainer review before merge. :: none

Reviewed October 20, 2026, 2:58 AM ET / 06:58 UTC (Revision 2).

@steipete
steipete force-pushed the steipete/perf-micro-boot-critical-path-20260919 branch 2 times, most recently from 81859bc to 40e2c4e Compare October 20, 2026 06:26
@openclaw-barnacle openclaw-barnacle Bot removed the docs Improvements or additions to documentation label Oct 20, 2026
@steipete steipete changed the title perf(gateway): reuse prewarmed bytecode without main-thread writes test(gateway): measure populated startup through usable session access Oct 20, 2026
@steipete
steipete marked this pull request as ready for review October 20, 2026 06:27
@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-20T06:56:41.665581Z d98c789 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 40e2c4ef36

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/bench-gateway-startup.ts Resolved
Use Node 26.8 read-only compilation caching while retaining writable worker caches and existing older-runtime behavior. Add populated-session startup measurements and trace the parallel prekernel catalog/runtime preparation.
@steipete
steipete force-pushed the steipete/perf-micro-boot-critical-path-20260919 branch from 40e2c4e to d98c789 Compare October 20, 2026 06:51
@steipete

Copy link
Copy Markdown
Contributor Author

The paired measurements are complete. The cache experiment improved the seeded-session RPC by only 0.36% cold and 1.93% prewarmed, below the recorded 5% threshold, so it has been removed. The final scope is startup tracing and the populated readiness/lifecycle benchmark.

The CI-reported raw fixture write now uses the existing async state writer, and the port-allocation review finding is fixed with a regression. A fresh fixture boot serves the seeded session and exits cleanly; all 28 focused tests pass and independent review is clean. The current head is d98c789; CI is running.

@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 the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 20, 2026
@steipete
steipete merged commit 23af78f into main Oct 20, 2026
134 of 135 checks passed
@steipete
steipete deleted the steipete/perf-micro-boot-critical-path-20260919 branch October 20, 2026 07:10
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
openclaw#178087)

test(gateway): measure populated startup through usable session access (openclaw#178087)

Add a populated synthetic startup workload and require successful access to its seeded session over WebSocket RPC. Preserve startup spans, reject unclean populated benchmark shutdowns, and bound high-port allocation.

Keep catalog and model-runtime preparation parallel while exposing their trace spans. The compile-cache experiment was removed after paired measurements remained below the 5% threshold; no runtime startup speedup is claimed.

Validation: 28 focused tests, real isolated Gateway session-access and shutdown checks, independent review, and all selected exact-head CI checks passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:feature Preliminary submission classification; full source review pending. gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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