r/programming • u/gilnett • Oct 16 '26
Learned Index Lab: Replacing B-Trees with streaming linear models in pure Rust (-99% RAM, 3x faster)
https://github.com/gilnett/learned_index_labInstead of pointer-chasing through B-Tree node hierarchies, this index models the key distribution using streaming piecewise linear regression with strict epsilon error bounds.
Lookups compute positions directly on the CPU ALU before a local L1 cache search, reducing memory by 99% and cutting latency by 3x.
191
Upvotes
View all comments
Show parent comment
13
u/gilnett Oct 17 '26
Great question. The short answer is cost versus return. Large enterprise vendors like Microsoft or Oracle have decades of battle-tested code in their storage engines. Rewriting that core layer is expensive and risky, and nobody wants to spend millions in R&D to replace something that already satisfies their SLAs.
More importantly, the practical scope is narrower than the headlines suggest. These huge 99% RAM savings and 3x speedups only apply to read-heavy, sorted, immutable data. Traditional B-Trees are still far better for real-world transactional writes, page locking, and concurrency. Saving 150 nanoseconds on an in-memory lookup also means very little once you factor in disk I/O, joins, and network overhead. That is why it makes sense for columnar systems and LSM tables, but not as a blanket replacement for every database.