DevTools Logo

Bloom & Cuckoo Filter Simulator

Bloom & Cuckoo Filter Simulator

Insert words, query them, and compare theoretical and measured false-positive rates. Seeded and deterministic.

Runs in your browser
Try an example

Words

4 to insert · 4 to query

Simulation

For 4 items in 64 bits the optimal k = (m/n)·ln 2 is 11; you use 3.
Bloom and cuckoo filters give no false negatives: "definitely not" is always right, "maybe in" may be wrong. Cuckoo supports deletion, Bloom does not.

Bloom bit array

0000000001010000000000001000001000000110000111100100000000001000

Double hashing: h₁ + i·h₂ mod m · 4 distinct inserted

False-positive rates

TheoryMeasured (5,000 unseen keys)On your queries
Bloom0.50%0.40%0 / 2
Cuckoo0.39%1.44%0 / 2

Bloom: (1 − e^(−kn/m))^k. Cuckoo: about 2b / 2^f at full load = 1.56%; more fingerprint bits lower it, larger buckets raise it.

Query results

appleBloom: maybe inCuckoo: maybe in
kiwiBloom: definitely notCuckoo: definitely not
mangoBloom: definitely notCuckoo: definitely not
bananaBloom: maybe inCuckoo: maybe in

Cuckoo filter

4 inserted · 0 failed · max 20 kicks · 8 buckets × 2 slots · load 25%

Fingerprint 8 bits; each item costs about f ÷ load = 32.0 bits.

About

Compare theoretical and measured Bloom filter false-positive rates while inspecting bits, fingerprints, kick chains, and insertion failures. All computation stays in your browser.

Examples

Inserted values always hit

Input
simulateBloomCuckooFilter(["apple"], ["apple", "durian"], { bitCount: 256, hashCount: 3, seed: 11 })
Output
apple -> { maybeIn: true, inserted: true }

Bloom filters have no false negatives, so every inserted member reports maybe-present.

Small m raises the FP rate

Input
theoretical at bitCount 16 vs 1024 (10 words, k = 3)
Output
rate(16) > rate(1024)

The (1 - e^(-kn/m))^k formula grows as bits per item shrink.

About this tool

Bloom Cuckoo Filter Simulator compares probabilistic membership with simulateBloomCuckooFilter(words, queries, options) (alias runFilterSimulation): a Bloom bit array with double-hashed positions plus a cuckoo table with fingerprint buckets, kick chains, and bounded failures. Results include bloomBits, bloomQueries ({ value, maybeIn, inserted }), theoretical and measured false-positive rates, and the cuckoo buckets/inserted/failed/kickChain.

Hashing is a seeded FNV-1a variant (hashString, unsigned and browser-reproducible): bloomPositions uses h1 + i*h2 mod m with an odd h2, cuckoo fingerprints mask to fingerprintBits, and index pairs XOR a fingerprint-derived alternate bucket. The theoretical rate is (1 - e^(-k*n/m))^k over distinct n.

Cuckoo insertion is transactional: both candidate buckets are tried first, then up to maxKicks evictions are attempted, and on failure the buckets roll back to a pre-kick snapshot while the value lands in failed. Same seed and options always yield identical kick chains.

How to use this tool

  1. Insert the word list

    Add the true member set — every inserted value must query back as maybe-present.

  2. Query members plus absentees

    Mix inserted words with never-added probes so measured false positives have a denominator.

  3. Tune m, k, and cuckoo shape

    Grow bitCount to lower the FP rate, adjust hashCount, and size bucketCount/bucketSize/fingerprintBits/maxKicks for the cuckoo side.

  4. Read rates and kick chains

    Compare theoretical versus measured FP rates, then inspect failed and kickChain for eviction pressure.

Use cases

Sizing a membership filter

Preview how bitCount and hashCount trade memory against false positives before shipping.

Demonstrating no false negatives

Show students that inserted items always test positive while absentees only sometimes do.

Stress-testing cuckoo eviction

Force tiny bucketCount/bucketSize tables to watch kick chains, rollbacks, and failed lists.

Common mistakes

Mistake:Reading maybeIn: true as definitely present.

Fix:A Bloom positive on a never-inserted value is a false positive — only maybeIn: false is conclusive absence.

Mistake:Expecting failed cuckoo inserts to leave partial state.

Fix:Failed kicks roll back to the pre-insert snapshot, so buckets are unchanged and the value appears only in failed.

Mistake:Comparing runs across different seeds.

Fix:Positions, fingerprints, and kick victims all derive from seed — keep it fixed for reproducible comparisons.

Frequently asked questions

What does this tool do?

It simulates Bloom plus cuckoo membership with simulateBloomCuckooFilter (alias runFilterSimulation): seeded FNV-1a hashing, double-hashed Bloom positions, fingerprint cuckoo buckets with kick chains, and theoretical (1 - e^(-kn/m))^k versus measured false-positive rates.

Can an inserted item ever test negative?

No. Bloom filters have no false negatives — every inserted word reports maybeIn true. Only never-inserted probes can surprise you with a false positive.

Is my word list uploaded or stored?

No. Hashing, bit setting, eviction kicks, and rate math all run locally in your browser.

What happens when a cuckoo insert fails?

Buckets roll back to the pre-kick snapshot, so they are unchanged; the value lands in failed with its kickChain preserved for inspection.

References & standards