Oriel — AI & technology worth noticing, every day.

From Skiplists to B+ Trees: Making Valkey Sorted Sets More Memory Efficient

Web page · https://valkey.io/blog/from-skiplist-to-b+tree

First seen by Oriel on .

AI summary

Valkey 9.2 replaces the skiplist backing large sorted sets with fbtree, a 61-way B+ tree variant that reduces per-member index overhead while preserving command behavior and improving several operations.

  • fbtree packs up to 61 pointers into 512-byte leaves, combines normalized scores with member bytes, and sizes nodes for jemalloc allocation classes.
  • Four-byte anchor features and SIMD narrow child selection, while contiguous nodes reduce dependent memory fetches compared with separately allocated skiplist nodes.
  • Linked leaves accelerate ordered scans, cached endpoint leaves provide O(1) access for pops, and dedicated fast paths handle sequential inserts and range deletions.
  • With five million 20-byte members, overhead fell 43% for sequential inserts and 36% for random inserts, saving approximately 109 MB and 92 MB respectively.
  • Benchmarks showed ZADD throughput rising 105% and ZREM 76%; however, they used PR #4206’s branch and were not rerun for the merged commit.

#valkey #b+ trees #sorted sets #memory efficiency

Generated by gpt-5.6-sol. Check the original for details.

Metric trends

Last 30 days · Up to 120 recorded samples per source and metric, with reposts kept separate · First and latest retained

Points

Score reported by the source.

  • Hacker News: 204, latest observation ; +188 over observed period since
  • Lobsters: 7, latest observation ; +6 over observed period since

Comments

Comment count reported by the source.

  • Hacker News: 71, latest observation ; +70 over observed period since
  • Lobsters: 0, latest observation ; 0 over observed period since

Aliases

SourceExternal IDURL
Hacker News50534387https://valkey.io/blog/from-skiplist-to-b+tree/ Read discussion
Lobstersixhrachttps://valkey.io/blog/from-skiplist-to-b+tree/ Read discussion