Valkey kills the skiplist, cuts sorted set overhead by up to 43%
Valkey 9.2 replaces skiplists with a high-fanout B+ tree variant for sorted sets, reducing per-member memory overhead by up to 43% and significantly improving write throughput.
read it It offers a clear, data-driven engineering postmortem on replacing skiplists with a cache-friendly B+ tree variant.
summary
Valkey 9.2 replaces the traditional skiplist implementation for large sorted sets with a custom high-fanout B+ tree variant called fbtree. The new structure uses a 61-way fanout, packed score-member layouts, and SIMD-accelerated lookups to minimize pointer overhead and cache misses. Benchmarks show a 36% to 43% reduction in per-member memory overhead alongside substantial throughput gains for write-heavy operations like ZADD and ZREM. This architectural shift addresses the inherent cache inefficiency of pointer-heavy skiplists on modern hardware hierarchies.
key points
- Fbtree achieves a 61-way fanout and packs scores directly with member bytes to reduce pointer indirection and fit jemalloc allocation classes.
- Sequential inserts reduced per-member memory overhead from 50.3 bytes to 28.5 bytes (a 43% drop), saving roughly 109 MB in a 5-million-member test.
- ZADD and ZREM throughput increased by 105% and 76% respectively, benefiting from shallower tree traversal and fewer pointer updates.
who should read it
Backend engineers and systems programmers interested in high-performance data structures and in-memory cache optimization.
discussion warm
consensus
Commenters widely agree that B+ trees outperform skiplists on modern hardware due to superior cache locality, noting that skiplists suffer heavily from cache misses despite similar asymptotic complexity.
pushback
Some commenters debate whether the PR description was written by AI, while others point out that competing projects like DragonflyDB and separate Redis teams implemented similar optimizations earlier.
B+tree were designed around optimized IO in the era of magnetic storage, they're inherently cache-friendly. Skiplists are the same thing as a b+tree but the structure is inverted, which makes skiplists more to concurrent writer-friendly than b+trees. Different tradeoffs.
It clarifies the fundamental hardware tradeoff between skiplists (which favor lock-free writer concurrency via inverted structures) and B+ trees (which favor cache locality).
Generated by an LLM from the article and thread. Check the sources before relying on it.