Skip to content

execd: the disk-writer pool is a constant of eight, with no inline mode - #750

Merged
capy-ai[bot] merged 3 commits into
mainfrom
execd/remove-disk-writers-flag
Nov 28, 2026
Merged

capy-ai[bot] merged 3 commits into
mainfrom
execd/remove-disk-writers-flag

Conversation

@jaredLunde

@jaredLunde jaredLunde commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

EXECD_DISK_WRITERS sized the off-runtime disk pool, and 0 restored writing job output inline on the event loop — precisely the bug #744 fixed (a stuck write held the runtime thread and every caller with it). It existed as a rollback switch, and under the no-rollback-flag rule the switch goes: a new sandbox gets the new binary, so no deployment has a use for the old mode and nobody should be able to run it.

Rebased onto main after #746-#749 landed (the ledger, the list/read buffer, the kernel child list, the one-file chunk layout); no conflicts, and everything below was re-run at the rebased head.

What is gone

  • The variable: out of config.rs (field, parse, USAGE), out of Options (the public field and its default), out of main.rs, out of the README table.
  • The branch it selected: let threaded = self.ctx.opts.disk_writers > 0 and everything it gated. Tailing::flush no longer has an on-runtime path, and TailStep::AgainYielding (the "give the runtime a turn between rounds" state) is gone with it.
  • The test that asserted the zero mode, with_disk_writers_zero_a_stuck_output_write_stalls_every_caller_as_before.

What stays

The pool, as DISK_WRITERS: usize = 8, with the same tokio::sync::Semaphore and the same Ctx::disk_turn gate. Output batches, the ledger write of a life change, a keyed start's claim and the retention sweep all take a turn, always. The constant's doc says what the number bounds and why: it is disk queue depth — how many writes are outstanding against the disk — not CPU, because each writer is a blocking thread that spends its time in write. A deeper pool only lengthens the queue on a slow disk; a shallower one makes a job's own tail wait behind unrelated writes. Anything past the pool waits its turn (the spool file holds what it wrote meanwhile), so the bound can delay a write and never drop one.

The before-state lives in the mutant, not in production

mut_tail_write_inline is a test-only Cargo feature that puts the batch back on the runtime, one round at a time, yielding between rounds — the exact path #744 removed. Under it, a_stuck_output_write_does_not_stall_an_unrelated_caller goes red, so the off-runtime property keeps a red run of its own after the flag is gone.

Two tests changed shape, and here is why each change makes them stronger rather than weaker:

  • writer_threads_are_bounded_by_disk_writers_and_the_rest_wait → writer_threads_are_bounded_to_eight_and_the_rest_wait: ten jobs through the pool, eight batches on the stuck disk, two jobs logging that they wait, most == 8. It also runs with EXECD_DISK_WRITERS=2 in the environment and requires eight batches anyway, so the test now pins the constant and fails if the variable is ever read again.
  • a_retention_sweep_waits_for_a_disk_writer_turn: it used to hold "the only turn" at EXECD_DISK_WRITERS=1. With a fixed pool of eight it now starts eight jobs so every turn is held, then proves the sweep's decision shows while its ledger write and unlinks wait.

Proof

Red runs at this head, none anchor-missing, tree clean afterwards (handoffs/CAPY-15/red-runs.py in the captain drive):

# mutation test red output
M1 mut_tail_write_inline (the batch on the runtime) a_stuck_output_write_does_not_stall_an_unrelated_caller left: None, right: Some(200) — /livez unanswered
M2 Semaphore::new(DISK_WRITERS * 1000) writer_threads_are_bounded_to_eight_and_the_rest_wait timed out waiting for eight batches on the disk and two other jobs waiting
M3 Semaphore::new(2) (the shape reading a knob would give) same same timeout — two batches, not eight
M4 the sweep's turn deleted a_retention_sweep_waits_for_a_disk_writer_turn the sweep unlinks a dropped job's spool while every turn is stuck

Green at this head on the pinned rust 1.92 (cargo test -p beyond-execd --locked --no-fail-fast, 396 s, every binary): lib 63, bin 8, auth_matrix 5, baseline 1, binary 3, conformance 2, embed 15, embed_callbacks 2, embed_hooks 5, endpoint 16, faults 15, guard 2, interval 3, job_escape 7, job_model 11, jobmark 7, jobproto 13, jobtable 1, keeper_model 2, ledger 10, oneshot_headers 4, os_model 2, output 7, pack 6, parsers 1, pipe_backlog 2, pty 15, reaper 1, restart 10, retention 15, route_hook 3, security 16, signals 1, startkey 9, timeout 2. clippy -D warnings, cargo fmt --check and dprint check clean. differential is flaky on the development host in both trees (its own thread report has the counts); CI runs it and is green here.

The slow disk, measured on the real binary

slowdisk.so (CAPY-8's LD_PRELOAD shim, rebuilt from slowdisk.c) bills 300 ms per 128 KiB written under the whole state and jobs tree. One job writes 8,488,896 bytes (seq 1 1200000); another connection asks GET /livez every ~2 ms while the output drains; then the whole output is read back and compared byte for byte. This head against main (e6a69b7):

binary disk output to the disk /livez p50 p95 max probes
main e6a69b7 fast 160 ms 0.16 ms 9.3 ms 28.9 ms 23
this PR fast 254 ms 0.29 ms 29.1 ms 31.3 ms 33
main e6a69b7 300 ms/128 KiB 39.78 s 0.27 ms 0.38 ms 7.1 ms 16,582
main e6a69b7 300 ms/128 KiB (2nd) 39.75 s 0.26 ms 0.47 ms 5.2 ms 16,513
this PR 300 ms/128 KiB 39.77 s 0.25 ms 0.37 ms 5.3 ms 16,665
this PR 300 ms/128 KiB (2nd) 39.76 s 0.25 ms 0.36 ms 4.5 ms 16,681

Every run: complete: true, 8,488,896 bytes, in order. So a job whose output takes 39.8 seconds to reach the disk costs an unrelated /livez 0.25 ms at p50 and 0.37 ms at p95 — the same numbers to within noise on both binaries, which is the point: the shipped behaviour is the shipped behaviour. The fast-run p95 spread (9.3 vs 29.1 ms over 23 and 33 probes) is one scheduler hiccup in a 200 ms burst, not a shape difference; the 16,000-probe rows are the ones that mean anything.

Not in this PR

Nothing else: tail.rs and mise.toml never named the knob, and neither do the drive's slow-disk shims (checked). ARCHITECTURE.md is updated in the same commit — the configuration list, the one-gate paragraph, and the tests list.

jaredLunde and others added 2 commits November 27, 2026 23:42
EXECD_DISK_WRITERS sized the off-runtime disk pool, and 0 restored writing
job output inline on the event loop — the bug #744 fixed, kept only as a
rollback switch. A new sandbox gets the new binary, so no deployment has a
use for the old mode.

The pool stays as DISK_WRITERS = 8 with the same semaphore and the same
Ctx::disk_turn gate; output batches, the ledger, a keyed start's claim and
a retention sweep all take a turn, always. The before-state lives on as the
test-only mut_tail_write_inline mutation, under which the off-runtime proof
test goes red.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@jaredLunde
jaredLunde force-pushed the execd/remove-disk-writers-flag branch from bb28ff6 to 52efd23 Compare November 28, 2026 00:15
…eads

The disk-writer pool is the constant DISK_WRITERS; the environment list in
ARCHITECTURE.md still offered EXECD_DISK_WRITERS as a knob, which would send a
deployment looking for a setting execd no longer has.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot added this pull request to the merge queue Nov 28, 2026
Merged via the queue into main with commit 345415c Nov 28, 2026
34 checks passed
@capy-ai
capy-ai Bot deleted the execd/remove-disk-writers-flag branch November 28, 2026 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant