Repository navigation
store: the caller chooses what a sync waits for - #8
Merged
Merged
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.
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.
Same branch and commits as #7, which GitHub closed when its base branch (#6, merged) was deleted. See #7 for the full description:
SyncMode(Full/Fsync/Barrier) andGlobalStore::set_sync_mode; a small publish's asset records ride inside its journal record (publishes above 16 KiB of records still write a pack). Consumed by terragov/cavs-db'sDurabilitymodes.