# Bloom Filters

> Source: <https://www.dotnetperls.com/2026_11_28_bloom-filters>
> Published: 2026-11-28 07:00:00+00:00

**Recommendation:** Use a cheap AI-generated Bloom filter to short-circuit lookups that are definitely absent before hitting a memory-efficient trie; the source paid $0.20 and recovered most of the trie's performance regressions.
More in the playbook "Controlling LLM cost": <https://wpnews.pro/playbooks/llm-cost>

A **Bloom filter** is a small amount of memory that is used to record "imprints" from **known elements** in a collection—like hashes. Each known element is added to it, and the hashes must never erase other hashes. This gives us a way to determine quickly if an element **may be present**, or is **definitely not present**.

If an element was added, its **hash** would have been added, and thus if its hash is not present in the memory of the Bloom filter it is never present. The Bloom filter can not tell us if an element is present for sure—only that it might be present.

In modern times, the best way to write a Bloom filter is to **prompt an AI** to write one. I had **Gemini 4 Neon** write one and it cost me $0.20. I added it to my program—the one that uses the space-efficient trie that Gemini also wrote—and used it to optimize out checks that would never be found (were definitely not present) in the trie. I recovered most of the performance regressions from the trie (which saves 95% of the memory of the previous version). So with the Bloom filter, I have both competitive performance and much reduced memory usage.

• I wrote this from memory, and then checked Wikipedia to see if I remembered correctly—Bloom is the name of some guy, so it should be capitalized.
