Make LargeSmt readers cheap point-in-time snapshots#985
Merged
sergerad merged 2 commits intosergerad-largesmt-reader-traitfrom May 1, 2026
Merged
Conversation
sergerad
approved these changes
May 1, 2026
|
@huitseeker am I understanding that with this we effectively have the ability to acquire a cheap read-only snapshot which won't block writers? Similar to how databases have a WAL to allow concurrent transactional reads while still writing? |
Collaborator
Author
|
@Mirko-von-Leipzig This is the native rocksdb snapshot: https://github.com/facebook/rocksdb/wiki/Snapshot and @sergerad was using it since 77bc5c4 — if only to copy the contents. Note it does not apply to the top 16-levels of the tree — which aren't in rocksdb — which are CoW, so writers will have to pay an in-memory clone at the time of first write. |
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.
LargeSmt::reader()pairs an upper tree snapshot with a storage reader. A live storage reader can mix an old top with new lower data, as noted in multiple review comments.So this makes
SmtStorage::reader()require a point-in-time snapshot.RocksDbStorage::reader()now returnsRocksDbSnapshotStorage, backed by a native RocksDB snapshot, instead of copying the whole database into memory. This addresses this comment. This effectively reverts the tack from #980, which "gave up" on performance considering #873 with the idea that this code, however unused, will tell us what to implement in the node.The other issue is that
reader()cloned the in-memory top, which is large, as noted here.LargeSmtnow stores the top asArc<[Word]>.reader()andclone()share it. Writers use copy-on-write before changing upper nodes.Also fixes the changelog PR link from #958 to #967