Repository navigation
perf(server): turn starts no longer queue behind checkpoint captures - #42537
juliusmarminge wants to merge 2 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosAll 64 scenario measurements match All 64 scenario measurements
Baseline: 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. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
… that turn's priority Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Closing after the A/B in a new
The priorities move the wait from the start of a turn to its end without shortening the turn, so this isn't worth the added scheduling complexity. Raw results are in the maintainer's |
The orchestration effect worker had 4 slots handed out FIFO. With many active threads, a new message's provider request waited for a slot behind other threads' git-bound checkpoint captures. In the server-metrics
workingscenario at 20 threads that wait had a median of 6–7 s. Raising the pool size cut the wait, but captures got the extra concurrency too. Git throughput is the real limit, so turn ends got slower and throughput did not improve (−18% turns/min on 4-vCPU Windows at 8 slots).Fix
Each effect type now has a priority. A
satisfies Recordmeans a new effect type has to pick one.runtime-request.respond, rollback.How claims work now:
CASEbranch, it keeps FIFO within each level, and it covers normal work too. A cap on interactive concurrency would add a third limit and still let normal work starve.EXISTSbranch in the claimORDER BY, computed from outbox rows at claim time, with no new state. The boosted job still counts toward the background cap of 4 and the non-interactive cap of 5, so git concurrency does not rise.I also tried the broader rule "every capture whose run is held ranks with interactive work", since a held run looks "working" to the user. In a quick A/B against this PR's first head it did not help: working.20
turnEndMsmedian +4% (−269 to 266), andtoRequestMsmedian got worse by 9% (−162 to 683). Captures are limited by the cap of 4 on git work, not by claim order, so ranking them higher only takes slots from turn starts. Ranking them as normal would change even less, because the working scenario has almost no normal work. So I kept the narrow rule: it costs nothing when no turn is queued and removes the wait when one is.The tests are deterministic, use
TestClockand have no sleeps:Benchmark
Run on cups (16 cores, load 1.22 / 0.86 / 1.27 at start),
server-metrics ab --rounds 3 --only working,pipeline. A is main34ca872cbb6, B iscd0296518ed(this head).Trade-off: at 20 threads, captures give way to other threads' turn starts, so
turnEndMsrises (median +71%, p90 +32%), while whole-turn timeturnMsstays flat. The inheritance rule does not show up in these numbers. Each working thread sends its next message only after its run ends, so a turn is never queued behind a capture. It applies when a user sends a message while the last turn's capture is still pending. In that case the capture no longer waits behind other threads' turn starts. With 5 threads and inpipelinenothing gets worse.working.heapMBPerThreadgoes from 0.38 to 0.58 (interval 0.14 to 0.37). The first head measured 0.48 → 0.56, so this looks like noise in a small per-thread fit.Implemented by Claude Opus 5.5 in Claude Code, running in T3 Code.
🤖 Generated with Claude Code