Repository navigation
test(perf): measure subscriber-visible session starts - #185389
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. |
ae14503 to
04eebf6
Compare
* test(perf): measure subscriber-visible session starts * test(perf): carry prepared mock response items
|
Follow-up from the sandbox lifecycle lane: |
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.tspath: 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 buildpassed (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.
Host: 1-minute host load 69.0 → 66.0. Sandbox: 1-minute host load 60.3 → 44.3.
Fresh host scope totals identified
worktree.preparationat 6,537 / 12,796 ms. Fresh sandbox totals identifiedchat.send.detail.attempt.setup.workspace.sandboxat 21,863 / 33,464 ms, includingchat.send.detail.attempt.setup.sandbox.workspace_selectionat 12,183 / 28,646 ms andchat.send.detail.attempt.setup.sandbox.layout.skills_syncat 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):
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.