Repository navigation
perf(server): runs finish when the provider turn ends, not after checkpoint capture - #41362
juliusmarminge wants to merge 2 commits into
Conversation
…kpoint capture Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosNo All 64 scenario measurements
Baseline: unavailable · PR result: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
…ttle after capture Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Rerun of the pipeline A/B on an idle cups (load ~1–2), with the merged noise floors from #41370. Merge base
The +50% GC pause from the first run does not reproduce: −5%, and the A/A runs mark GC pause too noisy to gate on. Turn end (reply's last byte → finished run) is 28% faster with an interval well clear of zero, and time per turn drops 6%. |
Problem
A run counted as finished about 1.5 s after the model's last byte. About 700 ms of that is turn-end checkpoint capture (about 10 sequential git commands, then ref lookups, the diff and the authored paths).
RunExecutionServicewrote a finished turn aswaitingand flipped it tocompletedonly after capture. Clients treatwaitingas active, so the run looked busy throughout capture. With the files-changed card gone (#41317), nothing in the timeline needs the checkpoint when the turn ends.Change
completed, withcompletedAtset to the turn end, in the same commit that enqueues thecheckpoint.captureoutbox effect. Interrupted and cancelled runs already worked this way.checkpointIdon the run. It no longer moves status orcompletedAt, and it no longer touches the root node. Runs stored aswaitingby older servers still use the old flip.main,waitingwas a barrier: steers, queued turns and hand-off checks saw an active run until capture committed, so steer deliveries already queued on the thread's effect lane settled first. To keep that:readCommandProjectionpresents the latest run aswaitingto command decisions while its capture effect is pending or running.requeueUnreadSteersand the run-end reactor wait for the capture commit, which repeats the run update.completed.Checkpoint readers while capture is pending
waitingundermain.getTurnDiff: only receives turn counts that clients read from existing checkpoints.checkpointturn items, so nothing shifts when capture lands.latest_stable: this source needs a run with a checkpoint. The dispatch now waits for the source's pending capture before it takes any thread lock (capture commits under that lock), so a fork right after a turn starts from that turn.Behavior changes
t3_thread_waitanddelegate_tasksettle at turn end, before capture.waiting_for_children(notworking) while its capture runs.waiting.completedwithout a checkpoint and the queue stays held. Undermainthe run stayedwaiting.Scope
Product decision by Julius and Maria: remove the files-changed card and capture turn-end checkpoints asynchronously. Layer 2 of 2, stacked on #41317.
Verification
node scripts/server-metrics.ts ab --only pipeline --rounds 3, harness at feat(scripts): server metrics time the turn pipeline and opening a large thread #41282 head 996169f, A =main65cd644, B = this branch b46422c; the later fork-wait commit does not touch the pipeline path, cups linux-x64):pipeline.turnEndMs.median(API stream end → finished run)pipeline.msPerTurnpipeline.gcPauseMsgcPauseMsis flagged worse with 3 rounds a side. I have not explained it; capture now overlaps the harness's next send. Per-turn time is unchanged.completedAtwas 08:23:25.563. The client dropped "Stop generation" at 25.977 (about 0.4 s of client latency). Capture then ran for about 30 s in the background and hit the existing 30 s VCS timeout (anerrorcheckpoint, old behavior). The client recorded no timeline layout change after the completion frame.RunFinalizationQueue.test.ts. The capture tests now cover a completed run (status andcompletedAtkept, nonode.updated); the legacywaitingcases still cover the flip. Tests and replay-fixture assertions that waited for thewaitingevent now wait forcompleted. The replay scenario harness counts a completed run as busy until its checkpoint lands. 18 affected server files pass in an isolated PID namespace (774 tests).vp run check:changedpasses: format, lint, knip, typecheck (9 packages), tests (26 files) and the react compiler check.docs/internals/overview.md"Turn completion and checkpoints" now describes completion before capture and the command-side hold.Model: Claude Opus 5.5 in Claude Code (T3 Code).
🤖 Generated with Claude Code