Repository navigation
perf(session): wait for control admission and share the group commit across store lanes (H20) - #9
Merged
Merged
Conversation
…loaded Run-lifecycle store calls made on behalf of already-admitted work (cancellation reads, reserved starts, compaction load/start/commit, reserved reloads, history search, every settlement path, the scheduler's claim, prompt-identity, review-context and final-text reads) now use `Priority::AwaitControl`, which waits for a `control_slots` permit. The thirteen `sleep(1 ms)` retry loops that polled `Overloaded` from those calls in `execution.rs`, `scheduler.rs`, and `subagents.rs` are deleted, along with the 64-attempt history-search cap. `Overloaded` remains the immediate answer for new client commands, feed attachment, replay pages, snapshots, and child creation, so admission control at the boundary is unchanged. The scheduler's `reserve_next_run_at_depth` previously failed the whole runtime when the control lane was full during a claim; it now waits. Regression: `saturated_cancellation_read_and_start_wait_without_failing_ the_runtime`, `saturated_prepared_rejection_settles_and_keeps_priced_ accounting_known_zero`, and `saturated_reserved_reload_waits_after_auto_ compaction` saturate the real control lane (256 slots behind a held worker) instead of injecting `Overloaded`; `lifecycle_store_calls_wait_ for_capacity_while_client_commands_are_rejected` pins the lane split at the store. The injected-`Overloaded` test hooks that can no longer fire are removed. Part of H20 (speed-first plan, D8). No protocol, descriptor, or schema change.
…er wakeups Attribution of the eight-stream output service gap showed it is fsync bound, not admission bound: each service round paid one group commit plus one fsync per interleaved control write (`command`, `start_reserved_run`, ~3 ms each on ext4/NVMe), and the scheduler's claim read (`reserve_next_run_at_depth`, issued after every settlement) closed almost every forming group at one or two jobs. Control-lane jobs now declare how they relate to a forming output group (`worker::Joins`): - `OutputGroup` (writes: commands, child creation/cancellation, run starts, settlements, prompt identity, recovery) join the group as savepoints and settle on its single commit. A control write dequeued when no group is open opens one, so consecutive writes share an fsync. The reply still waits for durability; persist-before-publish is unchanged. - `Never` (client reads: snapshots, replay pages, cancellation reads) runs alone and closes a forming group, so it is answered right after that commit and never observes uncommitted state. - `AfterGroup` (the scheduler's claim read) runs alone after the group commits but does not cut the group short; it is a wakeup, not a waiting client. At most one read is held per group and no further control message is dequeued once one is, so control-lane FIFO order is preserved. Interleaved A/B, 30 pairs, eight-streams focused fixture, medians / p95: completion 283.7/310.1 -> 209.8/228.4 ms; control latency upper bound 19.7/24.2 -> 15.9/18.4 ms; cancellation 25.9/29.8 -> 23.1/27.2 ms; output service gap 24/28 -> 20/33 ms (27 of 30 samples 18-22 ms; three outliers 33-38 ms; a 15-pair same-binary A/A shows 20/21-23 ms). RSS unchanged. Regression: `a_waiting_control_write_joins_the_output_group_and_a_read_ does_not`. Part of H20 (speed-first plan, D8). No protocol, descriptor, or schema change.
- ADR-0011: one commit discipline across store lanes; wakeups do not close groups. Supersedes D8's admission-only framing. - architecture.md § Persistence: describe `Joins`, the two admission modes, and that commands, starts, and settlements share the stream's fsync. - speed-first plan: status block, D8 collapsed to its receipt and remaining acceptance, task index (H20 in review, H21 next), Phase 6 acceptance progress, cancel polls moved to H22. - Ledger: baseline, slice 1 A/B, the two probe attributions (fsync per control write; scheduler claim closing groups), and the H20 receipt with A/B and A/A tables. decisions-needed #5 resolved; root ADR allocation updated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
H20: wake-driven control admission and shared commit across store lanes
Spec: docs/plans/speed-first-extensible-agent-harness.md#d8--control-admission-and-shared-commit-h20-implemented
ADR: docs/adr/0011-shared-commit-across-lanes.md
Ledger: docs/plans/progress/speed-first.md (2026-09-09 entries)
What changed
Admission (
ab6de6f). Every store call the runtime makes on behalf ofalready-admitted work (cancellation reads, reserved starts, compaction
load/start/commit, reserved reloads, history search, all settlement paths,
prompt identity, review context, final text, the scheduler's claim) now uses
Priority::AwaitControland waits for acontrol_slotspermit. The thirteensleep(1 ms)loops that polledOverloadedinexecution.rs,scheduler.rs, andsubagents.rsare deleted, along with the 64-attempthistory-search cap.
Overloadedremains the immediate answer for new clientcommands, feed attachment, replay pages, and snapshots, so admission control at
the boundary is unchanged. Bug fixed along the way: a full control lane during
reserve_next_run_at_depthpreviously failed the whole runtime; it now waits.Shared commit (
d05e474). Attribution showed the eight-stream output gapis fsync-bound, not wake-bound: each service round paid one output-group
commit plus one ~3 ms fsync per interleaved control write (
command,start_reserved_run), and the scheduler's claim read closed 17 of 18 forminggroups at one or two jobs. Control-lane jobs now declare
worker::Joins:OutputGroup— writes join a forming output group as savepoints and settleon its single commit; a write dequeued with nothing open opens a group, so
consecutive writes share an fsync. Replies still wait for durability.
Never— client reads run alone and close a forming group; they areanswered right after that commit and never observe uncommitted state.
AfterGroup— the scheduler's claim read runs alone after the group butdoes not cut it short (it is a wakeup, not a waiting client).
At most one read is held per group and no further control message is dequeued
once one is, so the control lane stays FIFO. Persist-before-publish is
unchanged.
Docs (
acf2f9d). ADR-0011 (supersedes D8's admission-only framing),architecture.md§ Persistence amended, plan status/task index/Phase 6acceptance updated, ledger receipt and probe attributions, decisions #5
resolved.
How verified
cargo test --workspace— 1220 passed / 3 ignoredcargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo build --workspacestore::tests::lifecycle_store_calls_wait_for_capacity_while_client_commands_are_rejectedstore::tests::a_waiting_control_write_joins_the_output_group_and_a_read_does_notsessions::tests::saturated_cancellation_read_and_start_wait_without_failing_the_runtimesessions::tests::saturated_prepared_rejection_settles_and_keeps_priced_accounting_known_zerosessions::tests::saturated_reserved_reload_waits_after_auto_compaction(the three
saturated_*tests saturate the real 256-slot control lanebehind a held worker instead of injecting
Overloaded; the injected-failurehooks that can no longer fire were removed)
Measurements
Eight-streams focused fixture, 30 interleaved A/B pairs, release workers,
host I/O pressure 13–21%
some avg10. Median / p95.804e254d05e47427 of 30 gap samples are 18–22 ms; the p95 is three outliers at 33–38 ms that
a 15-pair same-binary A/A (20 / 21–23 ms) does not reproduce. The median meets
the carried 20 ms target; the executable budget stays at 50 ms until a
quiet-host recording qualifies p95. A lone command still costs exactly one
fsync (fan-out ack medians unchanged). Raw reports, worker binaries by SHA,
and pressure snapshots are under
target/qq-perf/h20-2026-09-09/(untracked).Compatibility
PROTOCOL_VERSION16,DESCRIPTOR_VERSION5, store schema 25: unchanged.Store::call_write/call_after_grouparepub(super).savepoints (sub-millisecond of SQL) before the shared fsync — still less
than its own fsync was.
Follow-ups / decisions needed
benchmarks/perf/budgets-v1.jsonfrom 50 ms to 20 ms (ledger row H20).qq-mcp,hosts/embedded.rs, andtools/shell.rspoll anArc<AtomicBool>and never touch the store;converting them to a
NotifychangesExternalToolHost::calland ismoved to H22.
RunIdentity,RunSettlement,PersistenceFault).