Skip to content

test(perf): measure subscriber-visible session starts - #185389

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-micro-ttft-harness-20260919
Oct 27, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-micro-ttft-harness-20260919

Conversation

@steipete

@steipete steipete commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The existing busy-Gateway turn-start harness measures preparation phases, but its first-text time is a server-side observation and its mock synchronizes all requests before streaming. That hides the latency a subscriber actually experiences when starting a session.

User Impact

No runtime behavior change. Performance investigations can measure a Control UI-equivalent new session through its initial-turn ACK, first provider request, first subscribed assistant delta, and first tool execution start, with fresh/warm p50 and p90 distributions and individual waterfalls.

Why This Change Was Made

Extend the existing turn-start-phases.ts / transcript-broadcast-measure.ts path: keep the 10,800-session, 40-plugin, 65-client workload, add four long retained histories, stream a mock preamble before real tools, and remove the mock cohort barrier only in turn-start mode. A separate exact subscriber records run-correlated receipts, including deliveries before the create ACK. Existing diagnostic scope names remain overlapping stage totals; the report explicitly does not invent per-run scope spans from their timestamps.

The added code belongs to the requested measurement harness, tests, and documentation; production Gateway code is unchanged. This is a tooling addition, not a performance optimization claim.

Evidence

Predeclared acceptance: every declared fresh/warm turn must acknowledge, reach the mock provider, deliver nonempty assistant text and a tool-start frame to the designated subscriber, and complete successfully. Wrong-session/run frames, empty frames, final-only text, tool results, and duplicate deliveries must not create or overwrite milestones. Reports must preserve independent socket ordering and report count/p50/p90 with server phases labeled as aggregates. Real proof uses the full fixture in host and Docker sandbox modes; small-sample timing tails are descriptive.

Validation: full pnpm build passed (33m08s on the loaded local host); 14 focused receipt/report tests passed (4.32s wrapper wall time); export-name guard and 185 closure/test-routing tests passed; changed-file typed lint and formatting passed. The first CI run found a TypeScript union-access error in the mock preamble builder; the repair carries its already-prepared message alongside its event list. The exact failing scripts typecheck now passes locally, targeted lint passes, and independent review confirmed event contents/order are unchanged. The live proof therefore remains applicable. No production Gateway code changed.

Review: independent subagent review (autoreview route unavailable), with no remaining actionable findings after fixing commentary/preamble event capture. Live validation also identified old global-quiet and synchronized-stream/window-fanout assertions that do not apply to independent first-token measurement under continuous background traffic; turn-start mode now validates exact per-run receipts and exact provider/tool work counts.

Both full-shape local runs passed: 32 complete per-run waterfalls, eight fresh and eight warm turns in each mode. All rows below are p50 / p90 milliseconds, including the 200 ms mock response delay. These are descriptive small-sample observations under different host load, not a host-versus-sandbox performance comparison or a runtime speedup claim.

Mode Cohort N Initial-turn ACK First provider request First visible assistant delta First tool start
Host fresh 8 954 / 5756 13776 / 14699 13986 / 14997 14083 / 15178
Host warm 8 140 / 252 1723 / 2934 1937 / 3142 2091 / 3203
Sandbox fresh 8 265 / 1181 27572 / 41194 27786 / 41398 27860 / 41432
Sandbox warm 8 211 / 451 4545 / 5384 4750 / 5606 4782 / 5672

Host: 1-minute host load 69.0 → 66.0. Sandbox: 1-minute host load 60.3 → 44.3.

Fresh host scope totals identified worktree.preparation at 6,537 / 12,796 ms. Fresh sandbox totals identified chat.send.detail.attempt.setup.workspace.sandbox at 21,863 / 33,464 ms, including chat.send.detail.attempt.setup.sandbox.workspace_selection at 12,183 / 28,646 ms and chat.send.detail.attempt.setup.sandbox.layout.skills_sync at 4,208 / 9,002 ms. These scopes overlap; they must not be summed.

Gateway artifact: a7fe06b17a966a1a1a518f805f85c7cbfaf9fee5; tooling was subsequently rebased without conflicts, with no intervening upstream changes to the three existing harness files. Both modes used 10,800 seeded sessions plus owned probe sessions, 40 plugins, 65 clients/eight exact subscribers, four concurrent turns, four 2,000-entry retained histories, 3,000 worktree files, and sidebar/list/search/history churn. The synthetic Git origin advances before fresh rounds. The host fixture was reused after setup recovery; the sandbox fixture was separate. Docker fixture containers were removed by the harness after the successful run.

Reproduction from a tooling checkout with this change (already-built Gateway entry; new output directories):

node --import ./scripts/tsx.mjs scripts/perf/turn-start-phases.ts --entry /path/to/build/dist/entry.js --output .local/session-start-host --port 52000 --cold-rounds 2 --warm-rounds 2
node --import ./scripts/tsx.mjs scripts/perf/turn-start-phases.ts --entry /path/to/build/dist/entry.js --output .local/session-start-sandbox --port 52010 --cold-rounds 2 --warm-rounds 2 --sandbox-image openclaw-sandbox:bookworm-slim

Early setup attempts (a port collision and obsolete quiet/synchronization/window-fanout assertions) are excluded. The default is 40 fresh and 40 warm samples for longer investigations. No production hot path changed, so this tooling PR makes no CPU/allocation improvement claim and does not run an optimization A/B stress campaign.

@clawsweeper

clawsweeper Bot commented Oct 27, 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 scripts Repository scripts size: L labels Oct 27, 2026
@steipete
steipete marked this pull request as ready for review October 27, 2026 03:35
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 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-27T03:51:32.428320Z 04eebf6 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.

@steipete
steipete force-pushed the steipete/perf-micro-ttft-harness-20260919 branch from ae14503 to 04eebf6 Compare October 27, 2026 03:49
@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 27, 2026
@steipete
steipete merged commit 49ef91c into main Oct 27, 2026
96 checks passed
@steipete
steipete deleted the steipete/perf-micro-ttft-harness-20260919 branch October 27, 2026 04:01
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
* test(perf): measure subscriber-visible session starts

* test(perf): carry prepared mock response items
@steipete

Copy link
Copy Markdown
Contributor Author

Follow-up from the sandbox lifecycle lane: turn-start-phases.ts still seeds a fixed 2026-10-25 clock. Once that is older than the fixture's 24-hour collector retention, ordinary startup maintenance reclaims the seeded cohort and the comparison changes shape. I am adding a current-clock default plus --now <epoch-ms> so both arms can share a fresh anchor, recording the actual fixture clock (including reuse), and updating the session-start measurement guide. Maintenance and production retention stay unchanged. Earlier setup timeouts will remain reported rather than treated as latency samples.

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. docs Improvements or additions to documentation scripts Repository scripts size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant