-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An optimal backend for the IAVL #140
Comments
One of the first issues, is the underlying persistence area is quite dumb and has little knowledge of what its storing, so you can't even optimize the storage much cause it just uses a https://github.com/tendermint/tendermint/blob/master/libs/db/types.go#L4 tendermint/db interface. It would be nice to know about the tree and info when doing persistence. Maybe nodedb should be pluggable or something even more higher level See https://github.com/tendermint/iavl/blob/master/nodedb.go#L37 |
According to Jae, IAVL tree already has Copy on Write semantics |
I wonder if it'd be worthwhile to explore an approach for iavl similar to what they're doing on the handshake project - creating a flat file database designed around the tree:
|
Assuming Urkle supports snapshotting, range queries/proofs and prefix iteration, can't it be used as a drop-in replacement for IAVL? |
Snapshotting - yes Additionally, you'll also need compaction. Essentially you're creating a custom database for the tree. Not a trivial thing to get right. But I bet the Tendermint team has the "chops" to do it 😃 I don't know about a drop-in replacement if Tendermint prefers AVL. There's primarily 2 versions of the Urkel tree: simple base 2, and radix like. |
#144 has a few ideas related to this, when this work is picked up please check that pr |
Had a quick glance over Urkle implementation, it seems the storage format is similar to our new node key format, index the nodes by order, we can also do a similar flat file storage like this. |
So I've been thinking a bit about the properties of an optimal backend for the IAVL tree.
We currently use a general purpose backend for the IAVL tree like leveldb.
This isn't optimal because general purpose back end because general purpose backends where not designed to store immutable data structures and locality properties of common data access.
Here are things we observe.
Some leaves are mutated frequently. Some subtrees are accessed every block. Others are infrequently red. We want to have a cache oblivious data structure that is optimized for this access pattern. Frequently mutated and red data should be stored together.
Ideally we would have copy on write semantics for the immutable data structure and we should be pulling lessons from purely functional data structures. Ideally we should never copy a leaves and nodes from a new version of the merkle tree. Instead we should track references to those nodes in unpruned versions and only delete the value when all the versions which reference a leaf/node have been pruned.
The text was updated successfully, but these errors were encountered: