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.
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.