You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Core] Share one fsync between concurrent segment appends #235
#198 moved compression, hashing and encryption off the pipeline lock. Each new segment's append and its fsync still run under the lock, on the runtime worker: NvramLog::append_records calls sync_data() once per segment. So concurrent writes still take turns on the fsync, and a worker can't run other tasks while it waits.
Running the append in block_in_place measured slower. On cargo bench -p capsule-registry --bench end_to_end -- write_concurrent_encrypted (four 16 MiB writers at once), it took 729 ms against 345 ms before #198. Without it, #198 takes 206 ms.
Where
Pipeline::place_chunk in crates/pipeline/src/lib.rs, and the append path in crates/nvram-sim/src/lib.rs.
Proposed direction
Group commit: segments appended while an fsync is in flight are written, then covered by the next single fsync, and each waiting write is told when its segment is durable. The ordering rule in docs/on-disk-format.md §6 must still hold: the data log is fsynced after a write's last segment and before its CAPSULE record goes to the journal.
Acceptance
write_concurrent_encrypted improves on 206 ms on the same machine, and single-writer throughput doesn't drop.
A test shows a crash after the append and before the shared fsync leaves no committed capsule pointing at a missing segment.
Leaving this open. Group commit can't live in NvramLog alone. write_from_reader (capsule-registry lib.rs) calls place_chunk with the pipeline mutex held, and place_chunk commits the storage transaction there, so append_records and its sync_data always run one writer at a time. A shared fsync inside the log would never have a second writer to share with.
The fsync has to move out of the pipeline lock:
StorageBackend gets an append that doesn't sync, plus a durability barrier that covers everything appended before it. That means every backend: NvramBackend, the storage root, InMemoryBackend, CachedBackend and the io_uring one.
The writers call the barrier unlocked, after their last place_chunk and before finish_write. That covers write_from_reader, the S3 PUT and UploadPart paths, and Complete, which commits the parts' segments. A dedup hit on a segment another writer hasn't made durable yet is covered too, because the barrier syncs everything appended so far.
The crash test from the acceptance list: append, cut the data log back to the last barrier, reopen, and check no committed capsule names a missing segment.
Missing the barrier on any one commit path loses data after a crash, so this is a durability redesign, not a tuning change. It should be its own fix/ branch, reviewed before it merges.
Activity
Bring the docs up to date with the soak's changes (#238)
saworbit commentedon Nov 16, 2026
Leaving this open. Group commit can't live in
NvramLogalone.write_from_reader(capsule-registry lib.rs) callsplace_chunkwith the pipeline mutex held, andplace_chunkcommits the storage transaction there, soappend_recordsand itssync_dataalways run one writer at a time. A shared fsync inside the log would never have a second writer to share with.The fsync has to move out of the pipeline lock:
StorageBackendgets an append that doesn't sync, plus a durability barrier that covers everything appended before it. That means every backend:NvramBackend, the storage root,InMemoryBackend,CachedBackendand the io_uring one.place_chunkand beforefinish_write. That coverswrite_from_reader, the S3 PUT and UploadPart paths, and Complete, which commits the parts' segments. A dedup hit on a segment another writer hasn't made durable yet is covered too, because the barrier syncs everything appended so far.Missing the barrier on any one commit path loses data after a crash, so this is a durability redesign, not a tuning change. It should be its own
fix/branch, reviewed before it merges.