Repository navigation
Conversation
…ssion's depth A write-back of DATA sent each 64 KiB extent to the disk by itself and waited for its answer before the next: an 8 MiB file was 128 writes, one on the device at a time, each a round trip from the file server through the NVMe driver and back, though 127 of them followed the one before on the device. Now the engine cuts and seals a reserved write's extents first, sends each stretch of contiguous sectors as one device write, and makes the extents' pointers once the bytes are there, a transaction each as before. The served disk asks every request of a write at once instead of one after another's answer, so the device holds as many as the session carries. The 8 MiB file is four device writes of 2 MiB, each sixteen requests in flight together. What fsync promises is unchanged: a pointer still exists only after its bytes completed, and the journal's flush before an entry still orders them before it. A write the device refuses leaves every extent as it was and stops the mount, as before; a stopped mount now refuses a reserved write before sending its bytes. Tests: one device write per stretch and no pointer at refused bytes; a reserved write of three extents cut at every request under torn and reordered writes; a write's requests all on the wire before the first answer, and each asked again across a session end. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tion, and a truncation removes as many Every 64 KiB extent of a write-back was a transaction of its own, and so was every extent a truncation removed: an 8 MiB file written over the last one was 256 transactions, each journaling the inode, the bucket and the accounting again beside its own extent and backpointer. On the AMD bench those transactions, with the checksums and buffers, were 6.1 ms of the round's 22.8 ms fsync, and their 188 KiB of journal made the commit three entries between five Flushes, 5.1 ms more; on the T14 in its drive's slow mode the Flushes alone were 12 ms and up. Now a reserved write points up to eight fresh extents of one bucket in a transaction, and a truncation removes up to eight whole extents of one bucket in one. The inode, the bucket and the accounting are journaled once for the eight. An extent that replaces old ones, or straddles the truncation's end, still goes alone. Counted on the host model, the row's round is 32 transactions and one journal entry of 14 blocks between two Flushes. Eight, by the transaction's own bounds: the largest such transaction is 263 u64s of journal against the bound of 512 and 8 nodes against the footprint of 28, on an encrypted volume, whose extent values are the larger; each extent more is an extent and a backpointer, in at most one node more of each tree. With 64 a transaction the engine's own assertion stops the new test at 746 u64s. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The A/B of #1216's code against main on both benches is judged: four boots an arm a bench, Linux in the same session. The record's "not yet established" named what the bench would read with the transactions grouped; it now carries those figures, where a round's time goes with the change, and what is still not established, the T14's fast mode with one boot an arm. The record stays open: neither bench reaches Linux's durable row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review: #1216 at e64953f (code cc718f6, base ad5db5a)ArchitectureThe responsibilities are split correctly. The engine owns the ordering: a reserved write's bytes complete, then its pointer transactions apply, then the journal's preflush puts them on the medium in that order. The engine also owns the grouping. The served disk owns request concurrency. It hands anything past its depth to the session's client, which already holds back requests that the ring or arena cannot take. Nothing changes in the format, the ABI or Crash consistency holds, by inspection.
The bound of 8 is safe, but the stated reason is wrong (finding 1). The journal measures 263 of 512 u64s. For nodes, my worst-case estimate with a populated LRU is about 20 of the 28 in A leak is not plausible from the changed paths.
ControlsI checked each one in its log. Each turned red as claimed:
The first three were run against 5a90355. Their tests survive unchanged at cc718f6, and the bytes-then-pointers structure is the same there, so reusing them is sound. Two limits:
Required
Description and record (orchestrator's)
What the T14's r5/r6 boots must show (LAND pending metal once 1 and 2 are resolved)
Suggestions (optional)
SEND BACK. Findings 1 and 2 must be resolved first. After that, LAND pending the r5/r6 boots under the criteria above. |
Review of #1216 found the derivation of POINTED false for the write side: each fresh piece of a pointing group went through point_extent and replace_data_keys with a bucket map of its own, so the group's bucket changed once a piece, and its fragmentation-LRU entry moved through every fill on the way. Each extra piece journaled an LRU key as well as its extent and backpointer, and on a volume whose LRU spans many leaves the group could touch a leaf a piece. A group of fresh pieces now builds its extent keys and calls replace_data_keys once, as trim_extents already does for removal: one bucket map, one alloc change, one LRU move from the fill before to the fill after. An overwriting piece is still pointed alone, its old extents read again inside its transaction, because an earlier piece may have left a slice of one. A fresh piece needs no such read: an old extent reaching its blocks would have made it not fresh. POINTED's comment now says what it bounds on both sides. Measured on the host (largest transaction, journal u64s and nodes; before the fix in parentheses): - streaming 5 MiB over 2 MiB buckets: plain 212 (247), encrypted 228 (263), 7 nodes either way; removal 202 and 8. - a full group moving its bucket's LRU entry from 1/16 to 9/16 full, on 1 MiB buckets of 16 KiB nodes: 203 (238) u64s; 6 nodes with the LRU in one leaf, 8 (11) with it spread over many leaves by 1500 buckets left at every fill. The margins the tests hold, a quarter of K_TX and half of FOOTPRINT, now include the LRU leaves on both volumes. Tests: - The crash-model test now groups: the old file lies under the first of three extents only, so the first is pointed alone and the other two together, and each transaction is committed as it applies (a test-only switch), so a crash can fall between any two. Every crash state holds none, the first or all three pointed, never two, and checks clean; the test also asserts that the crashes cut between the lone extent and the group. - The bounds test asserts the write took one pointer transaction for each POINTED extents (one more on the encrypted volume, its version mark), and a new test measures a group across LRU leaves. - A new test runs the bench's sequential round on 512 KiB buckets six times, remounting between rounds so emptied buckets are refilled in groups; fsck is clean after each round, and once the file is gone the empty-bucket count is what it was before the first round. Negative controls, each applied, run and reverted: - grouping off (no piece fresh): the crash test sees two of three pointed, the bounds tests count 80 and 8 transactions; red. - a refilled bucket drained one sector short: the reuse test's fsck finds alloc keys that differ from what the extents derive; red. - a bucket change a piece (the code before this commit) stays green: its footprint is within the margins too, by the figures above. Also from the review: write_reserved reads its inode once before cutting, finds stretches and groups with chunk_by, carries its own doc instead of the module header, and the bounds test prints nothing; the served disk's write says "failure" where it meant one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#1216's code changed in review, so its bench figures are of cc718f6 and the reviewed head is still to be measured. The T14's DATA free figure fell by 512 KiB after one boot of that code and after no other: one more occupied bucket or one more btree node, with what the next boots' mount lines would show for each. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review r2: #1216 at d3d67f8 (code da1c40c, base ad5db5a)This review covers r1's two required findings, the code changed since e64953f, suggestions 9 and 10, and the second A/B's rules. I built and ran nothing. The evidence was read at evidence ef5b289. ArchitectureThe architecture is unchanged and still right. The engine owns the ordering and the grouping. A group of fresh extents now goes through one bucket map, the shape Finding 1: resolved
Finding 2: resolved
Suggestions 9 and 10: verified
Evidence
FindingsNo blocker. Notes on the second A/B's rules.
Suggestion (optional). In the PR description's Checks section, "At da1c40c's code" should read "on the tree committed as da1c40c, but for one comment", as the evidence says. What must show before landing
LAND, pending the guest row and the second A/B as above. |
Both benches are down with no date for their return, and #1216 lands on review, host checks and its guest row. The second A/B that was to measure the reviewed code was staged and never ran, so the record says plainly that the landed code's speed-up is not measured on metal, and names what main owes when a bench returns: the A/B of main from before and after #1216 with DATA carried over and every free figure recorded, the durable rows against Linux on the same drive, and the reboot round trip on the T14. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Orchestrator verification, landing under the benches-down rule (metal unavailable; review + host + guest, metal owed):
|
…ved-write pieces Main moved 64 commits. Four files conflicted, and one call stopped compiling: - kernel/src/object/paged.rs: #1245's read returns once a copy reaches the read's end. Here that return sits where no write met the read, before it reads again. - kernel/src/syscall/paged.rs: #1246 looks a holder up under the handle table's own lock. The lookup keeps that form and checks the right each call needs (READ for a read and a statement, WRITE for a write). - lib/bcachefs/src/engine/tests/data.rs and the memory filesystem's record: both sides added beside each other, and both are kept. - #1216 split write_run into span, fill, seal and point_extent, and gave reserved writes their own planned path, dropping the reserved sector write_run took. The placed pool's writes take the sector their pool holds again: write_run has the optional placement it had, now over main's pieces, and the placed write checks the volume is writable as a reserved write does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The merge kept a pool's writes on the path #1216 removed: one extent a transaction, each waiting for its device write before the next, so 8 MiB of pool write-back cost 128 serial device writes where #1216 sends 4 at depth. After #1258 the pool carries most small writes to DATA, so the merge would have undone #1216's gain for them unseen. A placed write now plans its pieces onto the pool's lowest unwritten blocks, taking them with a cursor so no two pieces share one, and shares the reserved write's second phase: every stretch of contiguous sectors sent once, then the pointers, up to eight fresh ones of a bucket a transaction, each block counted written by its sector as its pointer lands. A pool keeps only its runs not written whole; a reservation goes once spent. write_run is main's again, so the engine writes reserved sectors one way, and a placed write checks the volume is writable before its bytes go, as nothing else does before the first transaction. A placed write over contiguous pool blocks is tested as a reserved one is: each stretch sent once, no pointer before, and a refused send leaving the file and the pool's blocks as they were. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Status: draft. Review r2 (on d3d67f8) is LAND. Both metal benches are down with no date for their return, so this PR lands on its reviews, its host checks and its guest row
nvme_disk_bootsat d3d67f8 (run 43070793437); the head, 7ad9bca, changes only the issue record and is code-identical. The speed-up of the code that lands is not measured on metal. Every gain figure below is cc718f6's, from the first A/B, before review r1's fix; the second A/B that was to measure the landing code was staged and never booted. What is owed on metal is listed below and in the record. This PR is a step: it does not reach Linux's figure.Problem
persist.seq_write_fsync(8 MiB in 1 MiB calls, thensync_all) reads about half Linux's on both benches: 243 to 274 MB/s against 493 to 520 on the AMD bench, 138 to 259 against 532 to 593 on the T14.Where a round's time went on main (diagnostic round, main with stage timers, 2 boots a bench)
AMD, ms a round, ToyOS against Linux on the same drive in the same session:
Of main's fsync: 128 device round trips, one at a time, 9.4 ms (the drive itself answered in 6.1); the extents' transactions, checksums and buffers 6.1 ms; the commit 5.1 ms, of which five Flushes 4.5; reading the pages out 0.9 ms. Linux sends the round as 66 writes of at most 128 KiB and one Flush.
T14: every ToyOS boot of that round ran in the drive's slow mode. Main's fsync was 35 to 47 ms: round trips 15, commit 12 to 23 (five Flushes of 2.3 ms and up).
Change
lib/bcachefscuts and seals a reserved write's extents first, sends each stretch of contiguous sectors as one device write, then makes the pointers.system/diskserver's served disk asks every request of a write at once. A round is 4 device writes of 2 MiB, each 16 requests of 128 KiB in flight together, instead of 128 awaited one by one.Eight comes from the transaction's own bounds. Each extent past the first adds only its extent key and its backpointer, in at most one node more of each of those trees; the bucket's LRU entry touches at most two LRU leaves for the whole group. Measured, largest transaction (journal u64s of 512, nodes of 28): a streaming write 212 and 7 (encrypted 228 and 7), its truncation 202 and 8, and a full group whose bucket's LRU entry moves from 1/16 to 9/16 full 203 and 6 with the LRU in one leaf, 203 and 8 with it spread over many leaves. Tests hold a quarter of the journal bound and half the footprint to spare on both volumes; with 64 a transaction the engine's own assertion stops it. Before review r1 each piece changed its bucket on its own: 247 and 263 u64s streaming, and 11 nodes on the spread LRU.
No interface changes and no manual page changes: the block layer's and the format's decisions stand.
The first A/B, of cc718f6 (before review r1's fix)
M is main ad5db5a with the
osbench_diskrow only, P this PR's code at cc718f6 with the same row only; no timers in either. Four boots an arm a bench, interleaved, and Linux'sosbench persistafter rounds 1 to 3. A T14 boot is in its drive's slow mode when itspersist.write_4k_fsyncp50 is over 3 ms; the T14 is compared mode by mode as well as over all boots.persist.seq_write_fsyncandfs.disk.seq_write.1048576, MB/s, each boot:fs.disk.*,nvme.*orpersist.*row is more than 5% worse in P and resolved, over all boots on either bench or in the T14's slow mode alone. The rows P reads worse at the median are unresolved and outside this change's path: on the AMD the file-server requests (fstat,stat,open_close,direct.*, 7 to 12%) follow where the client and the server ran in each boot, slower across LLCs or on what look like two threads of one core, and the memory file system's rows, which this change does not reach, split the same way in both arms; on the T14fs.disk.seekandfs.disk.read_4k, which answer in under a microsecond without a request to the server, in code this PR does not change.osbench_disk, the round trip underbench_data_survives_reboot; a local, uncommitted patch only pointed them at a copy of the benches' records). Every boot mounted DATA once and formatted nothing, found its directories, and logged no DATA error, failed or reissued request,Lostflush, stopped mount or panic; every test exited 0. The reboot round trip at the head (256 KiB written and synced, read back after a reboot) passed both boots on the T14.Where the round goes at cc718f6 (one boot a bench with stage timers)
Durability
Unchanged. A pointer is made only after its bytes completed, and the flush before a journal entry still orders them first; a commit still ends with a Flush after its last entry. Grouping changes how many keys one transaction carries, not when anything becomes durable, and a group is one transaction, appended whole to one journal entry. Evidence: a crash-model test of a three-extent reserved write whose first extent replaces an old one and whose other two are fresh in one bucket, each transaction committed as it applies (a test-only switch) and the device cut at every request, torn and reordered: every crash state holds none, the first or all three extents, never two, and checks clean, and the crashes do cut between the lone extent and the group (red with grouping off: two of three at request 16). Also the existing crash suites, and a control in which pointers are made before the bytes (2 tests red). On metal, 256 KiB written, synced and verified after a reboot passed on the T14 at 5a90355 and at cc718f6. One behavioural difference: a stopped mount refuses a reserved write before sending bytes.
Checks
cargo clippy -p bcachefs -p diskserver --all-targetswith the workspace's adopted lints and-D warningsexit 0. The record commit d3d67f8:cargo test --lib sourcegateexit 0. The fullcargo run -- --ci hostwas not rerun (the owner's testing policy: touched crates only; the merge queue runs it).nvme_disk_boots(DATA served off the NVMe driver's real session; QEMU x86-64): pass at 5a90355 and cc718f6, runs 42986107985 and 43018266273; at d3d67f8, the code that lands, run 43070793437, queued. It is the landing condition for the code; QEMU's clock gives no timing claim.cargo run -- --ci hostat cc718f6: exit 1, 109 of 110 steps green; the red is the macOS-only llvm environment test (issues/the-llvm-environment-test-breaks-git-on-macos.md), which this branch does not touch.passedand its row judge1 passed, 0 failed. Nothing of the code that lands has run on metal: the second A/B (the reviewed head against main, ABBA on each bench; rules fixed before staging and amended before any boot) never booted, because both benches went down. Its images are deleted; what it was to establish is owed, below.cargo test --lib sourcegateexit 0. No guest run for it: it changes only the record.Record
issues/a-sequential-durable-write-on-data-runs-at-about-half-linuxs.mdis new, carries the first A/B's figures and split and what is owed on metal, and stays open after this PR.Owed on metal (in place of the metal landing conditions)
When a bench returns, main after this PR owes, as the record states:
osbench_disk(files,nvme,persiston the bench's NVMe), on the T14 and the AMD bench, ordered before, after, after, before on each bench, with DATA carried from boot to boot and every mount'sbytes freerecorded. Main after must show every boot passing its row judge; DATA mounted once, nothing formatted and no refusal from the storage path; nofs.disk.*,nvme.*orpersist.*row more than 5% worse and resolved;persist.seq_write_fsyncandfs.disk.seq_write.1048576above before's; and no drop of the free figure at the mount after one of its boots. The T14's fast mode needs two boots a side or is reported as not established.osbench persistunder each bench's Linux on the same NVMe, in the same session, on both benches; the record closes when main is at or above Linux's.bench_data_survives_rebooton the T14: 256 KiB written and synced, read back whole after a reboot (passed at cc718f6).Not established, and risks
Review history
POINTED's derivation was false for the write side: each piece changed its bucket, so its LRU entry, on its own. Fixed as preferred: one bucket map a group, measured on a fresh and a spread LRU. (2) The crash-model test never grouped. Fixed: the old file lies under the first extent only, transactions are committed as they apply, and only 0, 1 or 3 extents pointed are accepted. Taken: suggestion 9 (the reuse cycle on 512 KiB buckets), 10 (a grouping count), 3, 4, 5, 6, 7, 8 and part of 2 (a fresh piece is no longer looked up again inside its transaction; an overwriting piece still is, because an earlier piece may have left a slice of its old extent). Not taken now: 1 (pointing each stretch as its bytes complete), the step toward overlapping the engine's work with the device, which changes the order of the write and is the next change rather than this one. The free-figure wording is the review's.🤖 Generated with Claude Code