Repository navigation
store: write the manifest before the beatree pages - #1001
Draft
citizen-stig wants to merge 2 commits into
Draft
citizen-stig wants to merge 2 commits into
citizen-stig wants to merge 2 commits into
Conversation
… changes The manifest used to wait for the beatree update (about 60 ms) before the hash-table pages could be written. Now each sync writes its value changeset to a small log (about 2 MB) alongside the hash-table WAL and the rollback delta, and writes the manifest once those are durable. The manifest keeps the previous beatree state and marks the log as pending (meta version 2). The hash-table writeout then runs while the beatree update finishes, and a second manifest write records the new beatree state. On open, a pending log is applied to the recorded beatree state; the beatree is copy-on-write, so pages written by the interrupted sync are free in that state. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 changed
value_logfile (store/value_log.rs, ~2 MB, fdatasync), alongside the bitbox WAL and the rollback delta.Metathat is read only for version ≥ 2.ht_io_pool), so beatree I/O doesn't queue behind 40k hash-table writes.Store::openreplays a pending log onto the recorded beatree state. The beatree is copy-on-write, so pages written by an interrupted sync are free in that state.PostMetapanic point now sits after the beatree pre-meta wait, so nothing is still writing in the background.Why it is faster
The hash-table writeout is protected by the WAL, which is durable early, but it also waited for the beatree update before the manifest could be written. Now the two overlap. Every write is still durable before
commitreturns.Measured
On its own with stock benchtop, the change is within noise (154 → 153 ms): the beatree's random leaf writes compete with the hash-table writes for the same IOPS. Combined with the staging-bypass and consecutive-leaves PRs, a node-profile benchmark went from 140.2 to 118.5 ms, and stock benchtop reached 90.4 ms with all four PRs (master: 152 ms).
Trade-offs
Tests
cargo test --workspacepasses.wal_recovery_test_post_meta_swapnow exercises the replay.🤖 Generated with Claude Code