Repository navigation
merkle: elide the third page level and keep costly elided pages in memory - #1002
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
…mory About 90% of the hash-table writes of a commit were third-level pages (bits 18-24), each with ~6 changed nodes: at 30M leaves each holds ~114 leaves, above the elision threshold of 20. Raise PAGE_ELISION_THRESHOLD to 255 so they are elided, and keep elided pages with at least 20 leaves in an in-memory map in the page cache, as of the last commit, so finish does not reconstruct them from leaves: - the page walker reports every elided page it changes, and pages that stop being elided; the merkle output carries them, an overlay keeps them, and the page cache applies them after the store commit succeeds; - seek uses a cached elided page instead of fetching leaves, and caches pages it reconstructs, only when there are no overlays below the session (the cache reflects committed state only). Stored pages carry no leaf counts and are never elided, so this applies to databases grown with the new threshold. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Forty commits over clustered keys in one process keep pages two levels below the root elided with 20-255 leaves, so they are served from the page cache's elided-page map between commits. The root is checked against a fresh database holding the same state. Fails if the walker's last elided pages are not reported (the cached page goes stale). 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
PAGE_ELISION_THRESHOLDgoes from 20 to 255, so pages three levels below the root (~114 leaves each at 30M keys) are elided instead of stored in the hash table.PageCachekeeps elided pages with ≥ 20 leaves in an in-memory map, reflecting the last commit.conclude_with_elided_pages. The merkleOutputand the overlay carry them, andNomtapplies them after the store commit, still under the access write lock.debug_assertchecks every cache hit against its parent node.Why it is faster
Per commit at 30M keys, ~90% of the hash-table writes were these third-level pages, each with ~6 changed nodes, on a drive limited by random 4 KiB write IOPS. They are derived data (hashes over leaves that are durable in the beatree), so they need no durable copy. After a restart they are recalculated from the leaves on first use.
Measured
Stock benchtop (setup as below):
Same final roots. Peak RSS +0.4 GB.
The database must be built with this branch, because it changes which pages are stored.
Limitations
finishrebuilds pages from leaves for ~20 blocks. A follow-up could rebuild the cache when the database opens.as u8cast allows.Tests
cargo test --workspacepasses. Newnomt/tests/elided_cache.rsruns 40 commits over clustered keys in one process and checks the root against a fresh database. It fails if the walker's last elided pages aren't reported, a stale-cache bug found during development.