Chapter 19Down the Rabbit Hole: Filters You Solve Instead of Fill
RocksDB's blog on switching some filters to Ribbon had one line that stuck: about 30% less filter memory at the same false-positive rate, roughly 7 bits per key instead of 10. In an LSM tree every SSTable carries a filter and they sit in RAM for hours. Firefox's CRLite moved from Bloom cascades to Ribbon cascades that users download at about 300 kB a day.
What I found is a family of filters that don't insert keys. They take the full set and solve for a table, and a sharp phase transition decides whether that works.
What a Bloom filter is paying for#
A filter has no false negatives and some false-positive rate ε. The floor is about log2(1/ε) bits per key: 8 bits for 1 in 256.
A Bloom filter needs about 1.44x that. An optimally tuned one has half its bits set, so each bit is a coin flip carrying less than a full bit of information. At ε = 2^-8 that's about 11.5 bits per key against 8, plus ~7 scattered probes per query, each a likely cache miss. My back-of-envelope: in a 10-billion-key LSM, 3 extra bits per key is 3.75 GB of RAM.
What the waste buys is insertability. But an SSTable is immutable, so for that data the 44% pays for a feature nobody uses.
Three cells that XOR to a fingerprint#
The XOR filter (Graf and Lemire, 2019) is trivial to query. Hash the key to three slots and an f-bit fingerprint. XOR the slots; if it equals the fingerprint, "maybe", else "no".
For keys in the set that must hold for every key at once, so the table is solved for: T[h0] ^ T[h1] ^ T[h2] == fp(key). For a stranger, the three cells hold values from other keys' random fingerprints, so the XOR is uniform and a match has chance exactly 2^-f. Memory is f times slots per key, so the game is how few slots per key still solve.
Peeling#
Gaussian elimination is cubic-ish. XOR filters use greedy peeling: each key is an edge touching three slots. Find a slot only one key touches, give that key the slot, push it on a stack, remove it, and repeat. Then fill the table in reverse: pop a key and set its private slot so its three-way XOR equals its fingerprint. Its other two slots are already final.
Ana: A0 B0 C0 fp=5 Ben: A0 B1 C1 fp=3 Cy : A1 B0 C1 fp=6 stack: (empty)
The phase transition#
Peeling gets stuck if every remaining slot has two or more keys. That knot is the 2-core, and if it's non-empty you retry with a new seed.
It's a cliff, not a slope. Let q be the probability a key survives peeling from one of its slots, with load c = n/m (keys over slots):
q = (1 - exp(-3 c q))^2q = 0 (everything peels) always solves it; a nonzero solution, a 2-core, appears suddenly past a threshold. Numerically c* = 0.8185 for three slots per key, so you need at least 1/0.8185 = 1.2218 slots per key: the XOR filter's "1.23".
slots/key 1.10 1.18 1.21 1.23 1.25
success 0% 0% 0% 82% 100%
─────────────────┤cliff├──────────The resulting 8-bit XOR filter came out at 9.85 bits per key with a measured false-positive rate of 0.4155% against a theoretical 0.391%. Three is the sweet spot: two slots per key only works below load 0.5, and four has a worse threshold (1.295 slots per key) plus another memory read per query.

Figure 2b from Graf and Lemire, "Xor Filters: Faster and Smaller Than Bloom and Cuckoo Filters" (JEA 2020), arXiv:1912.08258, licensed CC BY 4.0. Cropped and recompressed.
Bloom's line is shallower because of the 1.44 factor, so the gap widens the tighter your target.
Binary fuse: windows#
The 1.22 threshold is for a uniformly random hypergraph. Binary fuse filters (Graf and Lemire, 2022) change the graph's shape. The table is split into segments; each key uses one slot in a starting segment and one in each of the next two. Keys near the ends have fewer neighbours, so peeling starts there and a wave moves inward from both sides. Walzer proved this spatial coupling pushes the threshold toward the limit: 1.125 slots per key with three positions, 1.075 with four.
The shipped query, and my fuse demo
FastFilter's C query:
hash = murmur64(key + seed); f = (uint8_t)(hash ^ (hash >> 32));
h0 = mulhi(hash, SegmentCountLength);
h1 = (h0 + SegmentLength) ^ ((hash >> 18) & SegmentLengthMask);
h2 = (h0 + 2*SegmentLength) ^ (hash & SegmentLengthMask);
return f == (F[h0] ^ F[h1] ^ F[h2]);The XOR with a mask instead of an add shuffles the position within a segment without crossing into the next one, which would break the window structure.
My fuse-style demo with 100,000 keys showed the cliff moving left: 0% success at 1.147 slots per key, 100% at 1.188. Not the library's 1.125 in pure Python, but well under plain XOR's 1.22.
Ribbon: do the linear algebra#
Ribbon filters (Dillinger and Walzer, 2021) skip graphs. Each key is one equation over GF(2): a starting row and a 64-bit coefficient word, with all nonzero coefficients inside a band of 64 consecutive columns. Insert row by row: if the pivot row is empty, store the equation; if taken, XOR with the stored one, shift off leading zeros, continue. The narrow band keeps each key to about a machine word of work.
Overhead is a few percent with a 64-wide band: under 10% in the paper, under 1% with an experimental variant. BuRR gets "well below 1%" by bumping the few rows that don't fit into a small fallback. Queries read only a 64-row window, about one cache line for 8-bit fingerprints, versus three random misses. My tiny Python Ribbon (w = 64, 20,000 keys) solved 7 of 10 seeds at 1.05 slots per key and 10 of 10 at 1.10, at 8.80 bits per key and 0.378% false positives.
Not free: RocksDB measured Ribbon construction at about 4.4x the CPU of Bloom (140 vs 32 ns per key) and query CPU up ~20%. Break-even is roughly an hour of filter lifetime, so RocksDB uses Bloom for fresh flushes and Ribbon for compaction output that will stick around.
Where it breaks#
- Duplicates kill peeling. Identical keys are identical edges; no slot reaches degree 1, so every seed fails. The current C binary fuse code drops duplicates on a failed round; other ports may just error. Deduplicate first.
- Adversarial keys. Knowing the seed, an attacker can force a 2-core. Use a secret random 64-bit seed per build.
- Adversarial queries. A false positive is deterministic per filter, so once found it stays one.
- Small sets. Size factor climbs below ~100,000 keys and can exceed a Bloom filter.
- No updates. Kuszmaul and Walzer proved (STOC 2024) that dynamic filters pay an Ω(n)-bit penalty over static ones. So some of Bloom's 44% is the inherent price of accepting inserts.
The question I'm left with#
You get two of three: near the space bound, fast to build, restart-free.
| Filter | Space | Build | Catch |
|---|---|---|---|
| Binary fuse | 8% or more over bound | fast | |
| Ribbon / BuRR | ~1% over | ~4x Bloom | |
| ZOR (Limasset, 2026) | within 1% | slower prototype | abandons under 1% of keys into a side structure |
Can a fast, deterministic build get under 1% with no side structure? Peeling is sequential and cache-hostile, and I found no mature GPU builder.
What nags me most: the 0.818 peeling threshold is the same object as the erasure-decoding threshold of LDPC codes, and spatial coupling is the trick that made coupled LDPC codes work. A data structure for skipping disk reads and an error-correcting code solve the same random-graph problem. That's the next hole.
Sources#
- Graf and Lemire. Xor Filters: Faster and Smaller Than Bloom and Cuckoo Filters (JEA 2020)
- Graf and Lemire. Binary Fuse Filters: Fast and Smaller Than Xor Filters (JEA 2022)
- Dillinger and Walzer. Ribbon filter: practically smaller than Bloom and Xor
- Dillinger, Hübschle-Schneider, Sanders, Walzer. Fast Succinct Retrieval and Approximate Membership using Ribbon (SEA 2022)
- Dietzfelbinger and Walzer. Efficient Gauss Elimination for Near-Quadratic Matrices (ESA 2019)
- Walzer. Peeling Close to the Orientability Threshold
- Limasset. ZOR filters
- Kuszmaul and Walzer. Space Lower Bounds for Dynamic Filters and Value-Dynamic Retrieval (STOC 2024)
- FastFilter/xor_singleheader
- RocksDB. Ribbon Filter
- Mozilla. CRLite: fast, private, and comprehensive certificate revocation checking in Firefox