Repository navigation
Conversation
Every sync point in the store went through Rust's sync_all, which on macOS is F_FULLFSYNC: the drive's cache flushed, milliseconds per call on a laptop SSD, and five of them in a cavsdb commit were three quarters of what the commit cost after the ledger stopped growing with the store. SQLite and PostgreSQL default to fsync(2) on the same machine, which is what the comparison against them was silently paying for. SyncMode names the choice — Full, Fsync, Barrier — and set_sync_mode applies it to the packfile, the record pack, the journal, the snapshot and their directory syncs. The order of writes does not change with the mode: a chunk is on its way to the drive before the ledger names it in every one of them. Full stays the default, because the store does not know what it is asked to hold.
orelvis15
force-pushed
the
feat/sync-mode
branch
from
September 3, 2026 23:05
b7cce1e to
e6bf176
Compare
A publish wrote its asset records to a record pack of their own — one file and one sync per commit next to the pack and the journal. For a one-file save that file is three kilobytes, and the sync it costs is the same as the ledger's. The journal record now carries a publish's records inline, so the ledger and the records are one append and one sync; the ledger keeps each asset's byte range in the journal, and a snapshot is written only after every record still living in a journal has moved into one record pack the snapshot can name. Reads follow the reference wherever it points: a pending publish, a journal, a pack, a flat file from before. Measured both ways before settling the rule. Every publish inline made a 200-asset commit's journal grow at 60 KB a save instead of 34, the snapshot rotate twice as often and the rotation carry the migration: commit-cost lost 16% at Standard. So a publish above 16 KiB of records still writes a pack and the journal only names it, which keeps commit-cost where it was (Standard 10,881 objects/s) and gives the one-file graph save the fewer files: 11.4 ms at Full against 14.2 with the pack, 4.6 at Standard against 4.9. A journal reference read from a pre-1.8 index.json is discarded, and a record whose journal is gone loses its record rather than blocking the save that would have moved it.
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.
What
Stacked on #6. Every sync point in
cavs-storewent through Rust'ssync_all, which on macOS isF_FULLFSYNC(the drive's cache flushed, milliseconds per call). SQLite and PostgreSQL default tofsync(2)there.SyncModenames the choice andGlobalStore::set_sync_modeapplies it to the packfile, the record pack, the ledger journal and snapshot and their directory syncs;PackWriter::finish_withtakes it,finishstaysFull.Full(default, unchanged)F_FULLFSYNCfsyncFsyncfsync(2)fsyncBarrierF_BARRIERFSYNCfdatasyncThe write order — chunks before the ledger that names them — is the same in every mode. Consumed by
cavsdb::Durability::{Full, Standard, Batch, Relaxed}in terragov/cavs-db#9.A small publish's records ride in its journal record. The record pack was a third file and a third sync per publish; for a one-file save it holds three kilobytes. The journal record now carries a publish's asset records inline, the ledger keeps each asset's byte range in the journal, and a snapshot moves every record still living in a journal into one pack before it is written. Measured with every publish inline first: a 200-asset commit's journal grew 60 KB a save instead of 34, the snapshot rotated twice as often and
commit-costlost 16%; so a publish above 16 KiB of records still writes a pack and the journal names it. With that rulecommit-coststays where it was (Standard10,881 obj/s) and a one-file graph save atFullgoes from 14.2 ms to 11.1–12.1.Tests
One per
SyncModeon a publish/reopen round trip, the mode helpers on a file and a directory, and the journal/record tests extended for inline records (a batch's records ride in its journal record; a snapshot moves them into one pack and reads follow). Workspace clippy (-D warnings), fmt and tests green.