A cuckoo filter adds dynamic item deletion to approximate set membership while using less memory and fewer cache misses than a space-optimized Bloom filter whenever the target false-positive rate is under 3%. In 2014, Bin Fan, David G. Andersen, Michael Kaminsky, and Michael D. Mitzenmacher showed at ACM CoNEXT that replacing a flat bit array with a compact hash table of short fingerprints eliminates the 3x to 4x counter tax of counting Bloom filters without sacrificing lookup speed.
The enabling trick is partial-key cuckoo hashing. A standard Bloom filter cannot clear bits on delete without breaking overlapping keys, while standard cuckoo hashing needs full keys to relocate evicted items. Fan and colleagues store only fingerprints (500 lines of C++) and recover alternate buckets via an invertible XOR, reaching 95.5% occupancy and checking at most two cache lines per query.
- Space beats Bloom below 3% error: a semi-sorted
(2, 4)-cuckoo filter undercuts a space-optimized Bloom filter (1.44 * log2(1/epsilon)bits/item) once target errorepsilondrops under 3% (crossover at 7.2 bits/item), fitting 128.04 million items in 192 MB at 0.09% error vs. Bloom’s 123.89 million items at 0.19% error. - Two memory probes per query: every lookup inspects at most two buckets (issued concurrently), avoiding the
k = log2(1/epsilon)scattered bit reads that cost standard Bloom filtersk = 7cache misses at1%error andk = 9in the authors’ 192 MB test. - 95.5% fill with 4-slot buckets: grouping entries into 4-slot buckets lifts cuckoo load factor
alphafrom 50% (b = 1) to 95.5% (b = 4), while semi-sorting packs each 16-bit bucket into 12 bits to save 1 bit per item. - Clean deletes, bounded duplicates: deleting removes one matching fingerprint without breaking colliding keys, provided the item was genuinely inserted and no key appears more than
2btimes (8times forb = 4).
Partial-key cuckoo hashing without full keys
In Pagh and Rodler’s classic cuckoo hash table, every key x maps to two candidate buckets h1(x) and h2(x). When both buckets are full, insertion evicts a victim key y to its alternate bucket by rehashing the stored key y.
A compact membership filter drops full keys and stores only a short f-bit fingerprint f = fingerprint(x). Without x, h2(x) seems unreachable unless you keep keys externally. Fan and colleagues solve this with partial-key cuckoo hashing, pairing two candidate buckets via XOR:
i1 = hash(x)i2 = i1 XOR hash(f)
Because XOR is its own inverse, any fingerprint f sitting in bucket i (whether i1 or i2) recovers its alternate bucket j purely from table state: j = i XOR hash(f). During Insert (Algorithm 1), if neither bucket[i1] nor bucket[i2] has space, the filter picks one candidate bucket at random, swaps f with a random entry e inside it, computes i = i XOR hash(e), and repeats up to MaxNumKicks times (500 kicks in the authors’ code) until an empty slot opens.
Crucially, you must XOR with hash(f), never raw f. Writing i XOR f with an 8-bit fingerprint touches only the lowest 8 bits of the bucket index, trapping displaced items inside a 256-bucket window and causing early insert failures. Hashing f spreads evicted entries evenly across the table.
Partial-key XOR also avoids the deletion bugs that complicate prior Bloom extensions. Counting Bloom filters pay 3x to 4x space for 4-bit counters. Quotient filters (QF) pack sorted remainders into linear runs, forcing deletes to shift trailing slots and update 3 metadata bits per item, slowing sharply past 75% occupancy. Naive d-left counting Bloom filters (dl-CBF) suffer false deletion: if x and y share one bucket across d partitions and collide on f, deleting x can erase y’s only copy, requiring extra per-entry counters and indirections.
In a cuckoo filter, if x and y share i1 and collide on f, then i2 = i1 XOR hash(f) ensures they share both candidate buckets. Removing one copy of f from i1 or i2 leaves the other intact, keeping false positives bounded by epsilon. Callers must only delete keys genuinely inserted; deleting an absent key that collides with a real member will remove that real member’s fingerprint.
The (2, 4) sweet spot and semi-sorting
Two forces govern amortized space cost C = f / alpha bits per item, where f is fingerprint width and alpha is load factor. Wider buckets raise alpha: with k = 2 candidate buckets, maximum load climbs from 50% (b = 1) to 84% (b = 2), 95.5% (b = 4), and 98% (b = 8).
Wider buckets, however, force each lookup to scan up to 2b slots. Each slot matches an absent key with probability at most 1 / 2^f, giving total false-positive probability 1 - (1 - 1/2^f)^(2b), roughly 2b / 2^f. Holding error below epsilon requires f >= log2(1/epsilon) + log2(2b) bits, yielding C <= (log2(1/epsilon) + log2(2b)) / alpha.
Sweeping b in Section 5.1 puts the practical optimum at b = 4 ((2, 4)-cuckoo filter). Above epsilon = 0.002, b = 2 edges slightly ahead, while for 0.00001 < epsilon <= 0.002, b = 4 minimizes space at (log2(1/epsilon) + 3) / 0.955 bits per item. Section 5.2 then reclaims 1 extra bit per item via semi-sorting: because slot order inside a bucket never affects queries, sorting four 4-bit fingerprints (empty slots as 0) produces only 3,876 unique multisets. Storing a 12-bit index (2^12 = 4,096 > 3,876) into a cache-resident lookup table compresses 16 bits down to 12, cutting cost to (log2(1/epsilon) + 2) / 0.955 (for f > 4, semi-sort encodes the top 4 bits and stores f - 4 bits raw).
Theory adds one caveat in Section 4: because i2 = i1 XOR hash(f) limits each item’s second bucket to 2^f choices, 2b + 1 keys hitting the same bucket pair will overflow it. Avoiding insert failure requires 4^(b * f) = Omega(n), or f = Omega(log n / b) bits asymptotically, unlike Bloom’s constant 1.44 * log2(1/epsilon). Because b sits in the denominator, practice stays clean: across tables up to m = 2^30 buckets (4 billion items), f >= 6 bits still sustains 95% occupancy at b = 4.
Compare five filters at 192 MB scale
To test real DRAM behavior past CPU L3 cache limits, Section 7 budgets 192 MB per structure on dual Intel Xeon L5640 CPUs using 64-bit CityHash (~20 ns per key). Standard and blocked Bloom filters get 13.00 bits/item (k = 9), cuckoo filters use m = 2^25 buckets of four 12-bit entries, dl-CBF splits entries across d = 4 partitions, and QF uses 2^27 slots capped at 90% occupancy. Switch tabs below to compare where each design wins or stalls across workloads.
Select a filter (or use Left and Right arrow keys) to inspect Table 3 space metrics, lookup curves across positive ratios, and insert/delete scaling.
Standard (2, 4)-Cuckoo Filter (CF): fast lookups and deletes
Best balanceStores 127.78M items at 12.60 bits/item with 0.19% FPR while keeping lookup and delete throughput high.
- Where it slows down
- Instantaneous insert throughput drops steeply past ~80% occupancy as recursive evictions approach the 500-kick limit, though overall build still hits 5.00M keys/s.
- Core advantage
- Issues two bucket reads concurrently for constant <=2 cache misses; delivers top delete throughput across all load levels and symmetric ~13-14 MOPS lookups at 0% and 100% positive queries.
- Workload quirk (Fig. 5)
- Lookup throughput dips slightly at p = 50% positive queries because CPU branch prediction hits maximum 50/50 uncertainty.
- Best fit
- Dynamic caches, routing tables, and indexes needing fast deletes, constant lookup latency, and ~0.1% to 1% FPR.
Semi-sorted Cuckoo Filter (ss-CF): halves error in equal RAM
Lowest FPRPacks 128.04M items in 192 MB (12.58 bits/item) and cuts false positives from 0.19% down to 0.09%.
- Encoding tax
- Table indirections per bucket cut construction speed from 5.00M to 3.13M keys/s and slow lookups relative to raw CF.
- Space payoff
- Reclaiming 1 bit per item via 12-bit sorted-bucket indexes doubles fingerprint precision over BF and CF in the same 192 MB budget.
- Speed vs. Bloom
- Even with bucket decoding overhead, ss-CF still outperforms standard BF once positive queries exceed 25% of traffic.
- Best fit
- Memory-tight systems targeting under 3% FPR (especially under 0.1%) where RAM savings outweigh write throughput.
Space-optimized Bloom Filter (BF): steady writes, multi-miss hits
No deleteHolds 123.89M items at 13.00 bits/item and 0.19% FPR using k = 9 simulated hashes, with zero deletion support.
- Why positive lookups drag
- Must verify all k = 9 bits across separate cache lines when items exist (or on false positives), trailing blk-BF by ~4 MOPS and trailing CF across positive workloads.
- Where it stays strong
- Constant insert throughput at every fill level (3.91M keys/s overall) and graceful FPR degradation if slightly overfilled instead of hard insert failure.
- Negative query shortcut
- Negative lookups stop at the first zero bit (averaging ~2 checks at 50% bit fill), making 100%-negative streams much faster than 100%-positive ones.
- Best fit
- Append-only or immutable filters (like SSTable blocks), targets above 3% FPR, or workloads that cannot tolerate bounded capacity.
Cache-line Blocked Bloom (blk-BF): fastest build, 2x higher error
No deleteConfines all k = 9 probes to one 64-byte cache line, hitting 7.64M inserts/s at the cost of 0.43% FPR.
- Hot/cold block skew
- Hashing each key into a single 64-byte block leaves some blocks crowded and others sparse, doubling FPR vs. BF (0.43% vs. 0.19%) and quadrupling ss-CF.
- Latency ceiling
- Caps every query at 1 CPU cache line miss, giving top construction speed (7.64M keys/s) and top negative-query speed when blocks stay sparse.
- Positive query drop
- Throughput falls steadily as positive ratio p climbs from 0% to 100% because hits must examine all k = 9 bit positions inside the block.
- Best fit
- Write-heavy, read-mostly negative filters where 1-cache-line speed matters more than deletion or compact error bounds.
Quotient (QF) and d-left Counting Bloom (dl-CBF) lose on load or space
Prior deletablesBoth prior deletable filters trail cuckoo filters in 192 MB: QF stalls under high load, while dl-CBF quits at 78% fill.
- Why both underperform
- QF chains slow lookups and deletes near 90% load (1.91M inserts/s); dl-CBF stops at 78% occupancy (103.82M items) and probes 16 entries, raising FPR to 0.76%.
- Relative bright spots
- dl-CBF maintains flat insert throughput (4.78M keys/s) and second-best deletes without relocations; QF hits 0.18% FPR at 13.33 bits/item when kept well below 75% full.
- Implementation cost
- QF must shift sorted clusters and update 3 metadata bits on every edit; dl-CBF needs extra entry counters to prevent false deletion.
- Takeaway
- CF replaces both for general in-memory deletable filtering unless sequential disk/flash locality specifically favors QF.
Source: Fan et al. (2014), Section 7, Table 3, and Figures 5 through 8.
Without clicking through each tab, the 192 MB benchmark comes down to five concrete tradeoffs:
CF: holds 127.78M items at 12.60 bits/item and 0.19% FPR, winning delete throughput and keeping lookups flat via two concurrent bucket reads while inserts slow near 95% full.ss-CF: packs 128.04M items at 12.58 bits/item and cuts error in half to 0.09%, beating standard Bloom lookups whenever over 25% of queries are positive.BF: holds 123.89M items at 13.00 bits/item and 0.19% FPR with flat 3.91M/s inserts, but cannot delete and loses lookup speed on positive queries acrossk = 9probes.blk-BF: builds fastest at 7.64M keys/s and caps lookups at one cache line, yet uneven 64-byte block loading doubles FPR to 0.43%.QFanddl-CBF: trail cuckoo filters in both space and speed, withQFbogging down in long probe clusters (1.91M/s build) anddl-CBFfailing inserts around 78% occupancy (0.76% FPR).
Caveats and when a Bloom filter still wins
Three operational limits in Fan et al.’s design explain why cuckoo filters complement rather than completely replace Bloom filters in storage and networking engines.
First, cuckoo filters enforce a hard capacity ceiling and suffer tail-latency spikes near full load. Once occupancy approaches 95%, an insertion may trigger hundreds of random swaps before either settling or failing at 500 kicks, forcing a full table expansion or rehash. By contrast, a Bloom filter accepts inserts indefinitely at constant speed (gracefully raising epsilon), and an immutable SSTable filter never inserts or deletes after compaction. Systems with unpredictable cardinality growth or strict write tail budgets must monitor load factor closely or size tables with headroom.
Second, deletable cuckoo filters break on heavy duplicate keys and unsafe deletes. Because deleting x requires preserving duplicate insertions of x (unlike a non-deletable filter, which can deduplicate fingerprints), inserting the same item 2b + 1 times (9 times at b = 4) fills both candidate buckets and triggers insert failure. Likewise, calling Delete on a key never inserted risks deleting a different item’s colliding fingerprint; applications need an authoritative record (or external index, just as caches paired with probabilistic refresh policies like XFetch or exact backing stores do, and unlike approximate similarity sketches such as SimHash near-duplicate detection) before issuing deletes.
Third, the space crossover sits near 3% false-positive rate (7.2 bits/item). If a workload tolerates 5% to 20% false positives, a standard or blocked Bloom filter uses fewer bits than a cuckoo filter’s (log2(1/epsilon) + 2) / 0.955 floor while staying simpler to resize.
For backend engineers choosing an approximate set today, the decision rule is straightforward: pick a standard or blocked Bloom filter for write-once indexes or high-error tolerances above 3%, and reach for a (2, 4)-cuckoo filter whenever you need under 3% false positives, dynamic deletes, or predictable 2-cache-line lookup latency in RAM.
