A prolly tree is similar to a B+ tree, but its node boundaries are determined by the data rather than by insertion order. Each node is addressed by the hash of its contents, and updates create a new root while sharing unchanged nodes with older versions.
This makes it useful when an application needs more than basic key/value storage: cheap snapshots, efficient diffs, three-way merges, deduplication, and incremental sync between replicas.
Some use cases I’m exploring include local-first applications, versioned database indexes, Git-like filesystem snapshots, agent memory and event logs, and reproducible RAG indexes where the exact data snapshot used for an answer can be recorded.
It’s a storage primitive rather than a complete database. The goal is to provide the ordered-map layer and let applications choose their own storage backend, data model, and conflict policy.
The project is still evolving, and I’d appreciate feedback—especially about real-world use cases, the API, and what is missing.
I started learning and implementing the prolly tree since December 2025, the current one crabbuild/prolly might be the 4th or 5th prolly tree implementation ;)
That's great. I spent the majority of my time at the Recurse Center doing a first implementation. The full rebuild version of an insert is trivial. The incremental version took most of the time.
Prolly trees have some funky properties too, for example deleting a value from a prolly tree can cause it to end up having more nodes than it started with..!! (So too can inserting a value result in fewer tree nodes)
Dolt had an interesting article on the subject, basically to get it more reliable in terms of similar size distribution they basically had a split threshhold function that shrunk by the current size, i did a bit of experimentation with statistics collection on a similar splitter and it was a bit of fiddling to get right in terms of how it should behave but it seemed to be possible to tune to specific block sizes.
Yeah I've read that article many times. I don't have such a mechanism at the moment. I'm not sure if I will until I run some of my own experiments.
I also have much smaller nodes than Dolt generally, and where they only hash keys to balance the tree, I also allow the value to influence the tree structure.
16 comments
[ 0.20 ms ] story [ 3.6 ms ] threadA prolly tree is similar to a B+ tree, but its node boundaries are determined by the data rather than by insertion order. Each node is addressed by the hash of its contents, and updates create a new root while sharing unchanged nodes with older versions.
This makes it useful when an application needs more than basic key/value storage: cheap snapshots, efficient diffs, three-way merges, deduplication, and incremental sync between replicas.
Some use cases I’m exploring include local-first applications, versioned database indexes, Git-like filesystem snapshots, agent memory and event logs, and reproducible RAG indexes where the exact data snapshot used for an answer can be recorded.
It’s a storage primitive rather than a complete database. The goal is to provide the ordered-map layer and let applications choose their own storage backend, data model, and conflict policy.
The project is still evolving, and I’d appreciate feedback—especially about real-world use cases, the API, and what is missing.
Upon insertion do you incrementally build the tree, or do you rebuild it from scratch?
How did you ensure the distribution of nodes was about the same with the chunker?
I just used the JS splice() contract for the main API abstraction. It maps perfectly onto prolly trees since it already allows bulk insertion and deletion: https://github.com/bablr-lang/agast-helpers/blob/7225f30e5e5...
Prolly trees have some funky properties too, for example deleting a value from a prolly tree can cause it to end up having more nodes than it started with..!! (So too can inserting a value result in fewer tree nodes)
I also have much smaller nodes than Dolt generally, and where they only hash keys to balance the tree, I also allow the value to influence the tree structure.
Conveniently: https://www.prollytree.com