Repository navigation
execd: a job's chunks in one file, a 72 KiB stride each - #749
Merged
Merged
Conversation
A job's output was one 64 KiB file an inode: 129 names for an 8 MiB job, an inode creation and a close per chunk written, an open and a close per chunk read. On this host a chunk's creation measured 36-45 us, more than the 7 us the 64 KiB copy into it costs (reports/CAPY-13.md). A job's chunks now go in one file, `ring/chunks`, at a stride of 72 KiB: chunk k's bytes at k * 72 KiB, its 8 KiB of stderr bits at + 64 KiB. A chunk's offset is arithmetic on its index; a flush is one `pwrite` on a descriptor the ring holds while it writes and drops when the job ends. Every invariant is kept, and each has a test that fails without it: - Offsets never move: the stride is a layout, not an offset; `read` and `attach` answer the same bytes before and after (tests/pack.rs compares them explicitly, and ring.rs's differential test runs both layouts). - A gap is declared, never silent, and a torn stride is never fabricated bytes: a chunk's bytes go down before its bits, so the file's length names exactly the chunks that are whole; recovery takes the base from the first data byte (lseek SEEK_DATA), never from the length, so a chunk the ring no longer holds is never served as zeros. A stride the journal had not passed is rebuilt from the journal byte-exactly; one the journal had passed leaves the gap a per-chunk file cut short leaves, and the ring starts at the journal's byte. - The 8 MiB floor and R3's window: eviction is one punch of one stride. - The stderr labels stay with their chunk, and a stdout-only chunk costs one pread and no allocation (the read reuses one 8 KiB buffer). - The tombstone drops everything at the same offset, and the ledger-then- unlink order is untouched. Eviction is now a punch, so the capability is probed once per directory and remembered; where the filesystem cannot punch (NFS, SMB, some FUSE) the ring keeps one file a chunk, the layout before this change, with a warning at start. That fallback is the filesystem's answer, not an operator's: there is no flag that asks for the old layout. Recovery reads the layout the files are in, so a ring directory holding chunk files is served and continued as one, whatever this run's probe prefers. One descriptor a running job did not hold before (its pack, closed when the job ends: an ended job holds none). Two of the three syscalls a chunk cost are gone; the journal's per-flush temp file is variant 2 of CAPY-13 and is not touched here. Measured on this host (release build, one 8 MiB job): 4 names in the spool instead of 131, 132 inode creations instead of 259, 2 fewer execd syscalls per 64 KiB chunk, and the job's wall time 73-76 ms -> 63-70 ms (medians of nine, alternating). Red runs: mut_pack_keeps_short_tail (a torn stride counted as a chunk: the torn test and the ring's own go red), mut_pack_ignores_punch_probe (the pack used where the filesystem cannot punch: the fallback test goes red), mut_pack_stride_overlap (the bits where the next chunk's bytes go: the stride test goes red). Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
The rebase onto 8a22dcc carried `Ring::new`'s new layout argument to every call site but one: the job `#747` added to the answer-equivalence test (`jobs.rs`, the serialized `read`/`list` fixtures). It compiles now with the per-chunk layout the sibling fixture uses; the test asserts the answer's serialization, not the layout, and pushes nothing into the ring. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
The red runs disproved a claim the pack shipped with: `a_pack_the_journal_outran_is_a_declared_gap` said it goes red under `mut_pack_keeps_short_tail`, and it stays green there. What declares that gap is the journal-floor trip in `Ring::recover_pack` (`end < floor` -> `set_len(0)`, `base = floor`), and no mutation reached it. Deleting the trip makes the test red (pack.rs:404); `mut_pack_ignores_journal_floor` is that deletion, in the crate's own idiom, and the two tests that pin the trip name it: this one and `ring::tests::a_pack_short_of_the_journals_byte_is_a_gap`. Test-only: with the feature off the code is the same statement it was. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
jaredLunde
force-pushed
the
capy/a-jobs-chunks-in
branch
from
November 27, 2026 22:56
80cae77 to
e0ce1a7
Compare
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.
A job's retained output was one 64 KiB file an inode: 129 names for an 8 MiB job, an inode creation and a close per chunk written, an open and a close per chunk read. Measured on this host, a chunk's creation cost 36-45 µs — more than the 7 µs it takes to copy its 64 KiB — so the inode, not the copy, was the tightest constraint in the output path.
This is variant 1 of
reports/CAPY-13.md. A job's chunks now live in one file,ring/chunks, at a stride of 72 KiB: chunk k's bytes atk * 72 KiB, its 8 KiB of stderr bits at+ 64 KiB. A chunk's offset is arithmetic on its index, never a table and never anything a client sends. A flush is onepwriteon a descriptor the ring holds while it writes and drops when the job ends, so an ended job holds no descriptor and areadopens the file once rather than once a chunk.Every invariant is kept, and each has a test that fails without it
readandattachanswer the same bytes before and after the change (read_and_stream_answer_the_same_bytescompares them over the same job), andring.rs's differential test runs both layouts through the same random pushes, reads and refused chunks.lseek(SEEK_DATA), rounded up to a stride), never from the length alone, so a chunk eviction punched is never served as zeros. A stride the journal had not advanced past is rebuilt from the journal byte-exactly; one the journal had passed leaves exactly the gap a per-chunk file cut short leaves today, and the ring restarts at the journal's byte.preadand no allocation (one 8 KiB buffer is reused).The capability gate, and no flag
Eviction is a punch, so
spool::punch_hole_supportedasks the jobs directory's filesystem once (a two-page scratch file, one page punched, removed) and remembers the answer per directory. Where it says no (NFS, SMB, some FUSE) the ring writes one file a chunk, the layout before this change, with alog_warn!at start saying why — that is the filesystem's answer, not an operator's, so there is no environment flag that asks for the old layout. Recovery reads the layout the files are in: a ring directory holding chunk files is served and continued as one, whatever this run's probe prefers (a probe answers per directory per run, so a remount can change it).Worst failure mode, and why it is bounded
A crash between a chunk's bytes and its bits leaves a length that stops inside a payload: at most the last 64 KiB reads back as a declared gap, never as zeros, and every earlier byte is exact. A crash whose journal advanced past the torn chunk leaves the retained window as one declared gap starting at the journal's byte. A disk that refuses a chunk takes the file back to where the ring's window started (
set_len), which is the same gap a refused per-chunk write leaves. The client always gets an answer with explicit gap ranges; there is no path that truncates, hangs or serves fabricated bytes.Rebased onto
8a22dcc1, and what the merge brokeThe branch was based on
87347af; main has taken four changes since, three touchingcrates/execd/src/jobs.rs(#746 ledger append, #747 serialized answers, #748 the kernel child list). The rebase itself was clean — none of the three landed on a pack hunk. One sibling call site broke: #747 added a secondJobfixture to the serializedread/listequivalence test, still callingRing::new(retain, dir), and that singleE0061was all four of this PR's red jobs at80cae77(build tests,execd (arm64),clippy, andCheckcounting them). Fixed in0d86902.Measured (release builds, one 8 MiB job; before = a release build of
8a22dcc1, re-taken because the base moved)8a22dcc1)ring/128)ring/1)pwrite)The chunk inode's create and close are exactly what goes missing: −2.0 ring syscalls per chunk, −128 inode creations, −127 names. The journal's rewrite count is unchanged (#746 made the ledger append-only, not the job journal), and at this workload's pacing the tail now takes more, shorter rounds — a pread and a journal append each — so the aggregate per chunk is flat. I do not claim the design report's "13.2 → 11.2 syscalls per chunk": the −2.0 is what the pack removes from the ring path, and it is handed back in the tail's round count. Wall time is inside this host's noise (three 41-round alternating runs: −13.4, −6.1, −0.6 ms on an 85-110 ms baseline, minima favouring the after binary in all three), so the portable findings are the names, the inodes and the ring path's syscalls.
Red runs
mut_pack_keeps_short_tail—a_torn_pack_tail_is_recovered_from_the_journalandring::tests::a_stride_the_crash_cut_short_is_not_a_chunk.mut_pack_ignores_punch_probe—a_punchless_filesystem_keeps_one_file_a_chunk.mut_pack_stride_overlap—the_stride_gives_every_chunk_its_own_bytes_and_labelsandread_and_stream_answer_the_same_bytes.mut_pack_ignores_journal_floor—a_pack_the_journal_outran_is_a_declared_gapandring::tests::a_pack_short_of_the_journals_byte_is_a_gap. Added after the red runs disproved a claim this PR shipped with: that test said it went red undermut_pack_keeps_short_tailand it did not. What declares that gap is the journal-floor trip inrecover_pack(end < floor→set_len(0),base = floor), and no mutation reached it; deleting the trip makes the test red atpack.rs:404, and this feature is that deletion. Test seam only.Each run is a Cargo feature (
--no-fail-fast, nothing in the tree touched), and in every one only the named test(s) failed.What is not proven
EXECD_TEST_FAULTseams (debug builds only) for a torn stride and a journal that outran the pack; a real machine crash between two writes is not driven in-tree.bytes_written / output_bytecame out 1.67-1.73 → 1.70-1.80, leaning slightly against the pack for the same reason as the tail's round count; the journal rewrite it is dominated by is a pre-existing per-chunk cost this change neither fixes nor worsens structurally.endpoint::shutdown_kills_every_running_groupflaked once in six reruns (shutdown_forreturnsended + groups.shutdown(..), which double-counts a job whose removal has not landed); that code is unchanged by this PR and is worth its own fix.retention::a_sweep_concurrent_with_remove_and_start_leaves_one_statealso flakes, leaving one spooljournalbehind — it does the same on a debug build of8a22dcc1(1 in 12 there, 3 in 25 here, and with the per-chunk layout too), so it is pre-existing and not this PR's.crates/execd/ARCHITECTURE.mdis updated in the same commit.