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 error epsilon drops 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 filters k = 7 cache misses at 1% error and k = 9 in the authors’ 192 MB test.
  • 95.5% fill with 4-slot buckets: grouping entries into 4-slot buckets lifts cuckoo load factor alpha from 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 2b times (8 times for b = 4).
Approximate membership filters compared at 192 MB (Fan et al., 2014)
Standard Bloom BF
No delete; k = 9 bit probes; 1.44x information-theoretic bound.
13.00 bits/item, 0.19% FPR, 3.91M inserts/s
Holds 123.89M items; positive queries pay up to k cache-line misses.
Blocked Bloom blk-BF
No delete; 1 cache miss via 64-byte blocks.
13.00 bits/item, 0.43% FPR, 7.64M inserts/s
Fastest construction, but uneven hot/cold blocks double FPR over BF.
Deletable Bloom variants
dl-CBF (d = 4) and Quotient Filter QF (90% max load).
13.33 to 15.51 bits/item, 0.18% to 0.76% FPR
dl-CBF stalls at 78% fill (103.82M items); QF drops to 1.91M inserts/s decoding chains.
Cuckoo CF and ss-CF
Supports delete; 2 bucket reads; 4 slots per bucket.
12.58 bits/item (ss-CF), 0.09% FPR, 128.04M items
Standard CF hits 5.00M inserts/s at 0.19% FPR; semi-sorting halves FPR in equal RAM.

Benchmark configuration and metrics from Fan et al. (2014), Tables 1 and 3 (Counting Bloom omits 192 MB row at 3x to 4x space).

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.

Three failure modes in partial-key cuckoo filters
Raw i XOR f

Skipping hash(f) confines 8-bit evictions within 256 buckets, causing local clustering and early insert failures.

Tiny f at billion scale

Bound f = Omega(log n / b) forces at least 6-bit fingerprints to sustain 95% fill near 4 billion items.

Over 2b duplicates

Deletable filters store duplicate inserts; inserting one key 9 times when b = 4 overflows its two buckets.

Failure conditions from Fan et al. (2014), Sections 3.1, 4, and 6.

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.

Empirical 192 MB comparison across space, accuracy, and throughput

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 balance

Stores 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.

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 across k = 9 probes.
  • 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%.
  • QF and dl-CBF: trail cuckoo filters in both space and speed, with QF bogging down in long probe clusters (1.91M/s build) and dl-CBF failing 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.