bbtree brings a faster ordered map to Rust data systems
bbtree is a new Rust ordered-map implementation designed to reduce cache misses in lookups and inserts. Its project report says it outperforms replaced skiplists by 1.37–6.83× across four LSM-tree systems, delivers 2.22× faster inserts and 1.90× faster indexed SELECTs in a Turso database comparison, and can memory-map an on-disk tree without rebuilding it after restart. The report also positions the structure for workloads such as agent memory, LLM training, RAG, KV stores, state caching and vector search.
The report presents concrete integrations and benchmarks for bbtree in storage and database systems whose underlying structures are used across AI workloads, including agent memory, RAG and KV stores.
What can it do?
B-trees are the most important data structure in big data systems, a fast b-tree like bbtree benefits everything on top of it: agents memory, LLM training, RAG, KV store, state caching, vector search, and more.
Here we discuss three representative use cases:
- Replace skiplist in LSM-trees. In place of the skiplist of four LSM-trees,
bbtreeis 1.37–6.83× faster. - In-memory database index. In place of Turso's skiplists, inserts are 2.22× and indexed
SELECTs 1.90× faster. - Mmap a bbtree from disk. No rebuild after a restart: the first answer comes 160–2,500× sooner than std's
BTreeMap.
All LSM-trees use an ordered map to hold recent writes in memory, the memtable. In Rust, this ordered map is usually a skiplist, like crossbeam-skiplist.
bbtree can easily replace it and is much faster. A skiplist takes a cache miss for almost every node it visits on its way down; a bbtree lookup touches a handful of cache lines (see How it works, below).