The floors

A floor on the bits

Answering membership for n keys with a false-positive rate of 1% and no false negatives requires at least 6.64 bits per key, whatever the structure. A Bloom filter uses 9.59. The gap is 44.27% at that rate and at every other rate, and it is the first bound on this site that a real structure comes close to.

Every floor on this site so far has been a floor on time. Comparison sorting needs log2(n!)\log_2(n!) comparisons; connectivity needs to read every edge; the floor moves when the question does and again when the values repeat. Five essays, one resource.

This is a floor on space, and it differs from the others in a way that matters more than the change of axis. The comparison-sorting floor is a bound nothing gets near — the best sorts sit a few per cent above it and the ordinary ones are off by factors that grow with nn — so it functions mostly as a proof of impossibility. This one is a bound that a structure people actually deploy sits 44% above, at every accuracy, for a reason with a name. That makes it a design target rather than a curiosity.

Bits per element: the floor, and what a Bloom filter needsFor each false-positive rate: the information-theoretic floor log₂(1/ε), which no structure answering approximate membership can get under, and the 1.4427× of it a Bloom filter needs at its optimal k. The overhead is the same factor at every rate — 1/ln 2, or 44% — so it is not something a better choice of parameters removes. It is the price of the particular construction, and it is why the cuckoo and quotient filters exist.bits per elementε = 0.13.3 → 4.8 (+1.5)ε = 0.035.1 → 7.3 (+2.2)ε = 0.016.6 → 9.6 (+2.9)ε = 0.0038.4 → 12.1 (+3.7)ε = 0.00110.0 → 14.4 (+4.4)ε = 1e-413.3 → 19.2 (+5.9)floor log₂(1/ε) filled; Bloom's log₂(1/ε)/ln 2 outlined44.3% above the floor at every rate
Fig. 1 Bits per element against the false-positive rate. The filled bar is log₂(1/ε), which nothing answering approximate membership can get under; the outlined bar is log₂(1/ε)/ln 2, which a Bloom filter needs at its optimal number of hashes. The ratio is 1.4427 at ε = 0.1 and 1.4427 at ε = 0.0001 — the overhead is a constant factor, not something that grows or shrinks with the accuracy demanded.

The argument, in full

The bound is a counting argument and it is short enough to give completely, which is the standard this site holds a floor to.

Fix a universe of UU possible keys and a set SS of nn of them. A structure answering approximate membership must say yes to every element of SS — no false negatives — and may say yes to some elements outside SS, subject to doing so for at most a fraction ε\varepsilon of them.

Now look at what the structure’s memory contents determine. Whatever the bits say, they determine a set of keys the structure answers yes to — call it AA. Correctness requires SAS \subseteq A, and the false-positive constraint requires An+ε(Un)|A| \le n + \varepsilon(U - n), which for large UU is about εU\varepsilon U.

So each possible memory state accepts a set of size at most εU\varepsilon U, and every one of the (Un)\binom{U}{n} possible sets SS must be covered by at least one state. One state can cover at most (εUn)\binom{\varepsilon U}{n} different sets — the subsets of size nn inside its accepted set. Therefore the number of distinct memory states needed is at least

(Un)(εUn)εn\frac{\binom{U}{n}}{\binom{\varepsilon U}{n}} \approx \varepsilon^{-n}

and the number of bits is the logarithm of that:

mnlog21εm \ge n\log_2\frac{1}{\varepsilon}

The approximation in the middle is the usual one for UnU \gg n; the result is exact in the limit and close enough at any real universe size. The number is per element and it does not involve UU at all, which is the surprising part of the statement: the size of the universe drops out. Storing the keys exactly would cost log2U\log_2 U bits each and grow as the keys get wider; accepting an ε\varepsilon of error costs log2(1/ε)\log_2(1/\varepsilon) bits each regardless of how wide the keys are.

That is the whole reason approximate membership structures exist. At ε=1%\varepsilon = 1\% the floor is 6.64 bits per key whether the keys are 32-bit integers, 64-bit hashes or 200-byte URLs.

What the floor says at each rate

ε\varepsilon floor, bits/element Bloom, bits/element extra
10% 3.32 4.79 1.47
3% 5.06 7.30 2.24
1% 6.64 9.59 2.94
0.3% 8.38 12.09 3.71
0.1% 9.97 14.38 4.41
0.01% 13.29 19.17 5.88

Two shapes in this table are worth naming.

The floor is logarithmic in the rate. Each factor of ten in accuracy costs log210=3.32\log_2 10 = 3.32 more bits per element. That is a very good exchange rate and it is why filters are used at all: going from 1% to 0.1% error costs 3.3 bits per key, which on a million keys is 415 kilobytes. The alternative — being wrong ten times less often by holding the keys — costs whatever the keys cost.

The overhead is a constant. 1.4427 at every row, to five figures. A Bloom filter is not closer to optimal at loose rates or at tight ones; it is 1/ln21/\ln 2 times the floor everywhere. That is checked rather than asserted — assertTheFilterFloorHolds requires the ratios across four rates to span less than 1.001, so a change that made the overhead drift would fail the build.

Where the 44% comes from

The constant is not arbitrary and its derivation explains what a Bloom filter is doing wrong, in the specific sense of what a better structure would do differently.

At its optimal kk, a Bloom filter’s table is exactly half full: the fill is 1ekn/m1 - e^{-kn/m} and substituting k=(m/n)ln2k = (m/n)\ln 2 gives 1eln2=121 - e^{-\ln 2} = \tfrac12. That is not a coincidence, it is what optimising kk does — the rate fkf^k is minimised where the marginal cost of setting more bits balances the marginal benefit of requiring more of them to agree, and that point is f=12f = \tfrac12.

A table that is half full of ones, with the ones in no particular pattern, holds exactly one bit of entropy per bit of storage. So the Bloom filter is at least using its bits at full information density — the waste is not there. The waste is that the information it stores is not only the membership information. A specific pattern of set bits records which keys were inserted and which of the kk hash slots each of them happened to land in, and the second part is noise the query does not need. The structure is spending bits on a record of its own arbitrary choices.

1/ln21/\ln 2 is how much of the storage that costs, and it is why the better constructions are all built the same way: store a fingerprint, not a footprint. A cuckoo filter or a quotient filter stores, per key, a short hash of the key in a slot chosen by another part of the same hash — so the bits record the key’s identity rather than the positions it happened to occupy. Those structures reach about 1.05 to 1.2 times the floor, and the extra machinery they need — displacement, a load factor below one, a bounded insertion loop — is what the 25% of space buys.

The same argument, twice

It is worth putting this derivation beside the comparison-sorting one, because they are the same argument in different clothes and seeing that is worth more than either on its own.

Comparison sorting. A sort must be able to produce any of n!n! orderings. Each comparison has two outcomes, so a decision tree of depth dd has at most 2d2^d leaves. To have n!n! leaves it needs dlog2(n!)d \ge \log_2(n!). The resource is comparisons and the counting is over outcomes the algorithm must distinguish.

Approximate membership. A filter must be able to represent any of (Un)\binom{U}{n} sets. Each memory state accepts at most εU\varepsilon U keys and so covers at most (εUn)\binom{\varepsilon U}{n} sets. To cover them all it needs εn\varepsilon^{-n} states, hence nlog2(1/ε)n\log_2(1/\varepsilon) bits. The resource is bits and the counting is over inputs the structure must distinguish.

Both are the same three-step shape: count the things that must come out differently, count how many the mechanism can separate per unit of resource, divide. That shape is what an information-theoretic bound is, and it is why it applies to algorithms nobody has written — it never mentions an algorithm, only what the answer has to distinguish.

The difference is what the resource is bought with. A comparison buys one bit of discrimination and an algorithm can waste it by asking a question whose answer it could have predicted. A bit of storage buys one bit of state and a structure wastes it by recording something the query does not ask about. Bloom filters waste in the second way, by 44%, and the previous section says exactly what they are recording that nobody needs.

The bound with numbers in it

The derivation is cleaner with a concrete universe, and the numbers are small enough to check by hand.

Take a universe of one million possible keys and a set of ten thousand of them, with ε=1%\varepsilon = 1\%. Then:

  • There are (106104)\binom{10^6}{10^4} possible sets, which is 280,7852^{80{,}785}.
  • Each memory state accepts at most 1%×106=1041\% \times 10^6 = 10^4 keys plus the 10410^4 real ones, and so covers at most (2×104104)=219,993\binom{2\times 10^4}{10^4} = 2^{19{,}993} sets.
  • The ratio needs at least 80,78519,993=60,792 bits80{,}785 - 19{,}993 = \textbf{60{,}792 bits}.
  • Divided by the ten thousand keys: 6.08 bits per key.

The asymptotic formula says log2100=6.64\log_2 100 = 6.64. The exact count comes out lower because the universe is only a hundred times the set, so being allowed to accept 1% of the universe is a large allowance relative to nn — the accepted set may be twice the size of SS rather than a negligible amount bigger. Widening the universe closes the gap:

universe exact floor, bits/key
10610^6 6.079
10710^7 6.573
10910^9 6.643
101210^{12} 6.644

So nlog2(1/ε)n\log_2(1/\varepsilon) is the large-universe limit, and at a small universe the true floor is lower. In the extreme, if the universe is only twice the set size, a bitmap of UU bits answers exactly and costs 2 bits per key, well under the “floor” of 6.64 — because at that ratio the counting argument’s approximation has broken down entirely. The formula is a floor for the regime it is derived in, which is the one every real filter is in: keys drawn from 64-bit hashes or from URLs, where UU is astronomically larger than nn and the limit is reached to four figures.

The condition is not that the universe is large

nlog2(1/ε)n\log_2(1/\varepsilon) is the large-universe limit” is the right reading of that table, and the condition it names is the wrong one. The universe being large is not what makes the limit accurate; what matters is the accepted set being large relative to nn.

The correction is computable. Expanding the exact ratio (Un)/(εUn)\binom{U}{n}/\binom{\varepsilon U}{n} to the next order gives a per-key floor of

log21ε    n2Uln2(1ε1),\log_2\frac{1}{\varepsilon} \;-\; \frac{n}{2U\ln 2}\left(\frac{1}{\varepsilon} - 1\right),

and the subtracted term is exactly what the table measures. At U=107U = 10^7 with n=104n = 10^4 and ε=0.01\varepsilon = 0.01 it is 0.071 bits, giving 6.573 against the measured 6.573. At U=109U = 10^9 it is 0.0007, giving 6.6433 against 6.643. Both to the digit.

Now read the correction’s shape. It is n/(2Uln2)n/(2U\ln 2) times 1/ε1/\varepsilon, which is n/(2εUln2)n/(2\varepsilon U \ln 2) — a function of nn divided by εU\varepsilon U, the size of the accepted set. So the asymptotic floor is accurate exactly when εUn\varepsilon U \gg n, and the universe’s size enters only through that product.

That is a considerably stronger demand than UnU \gg n when the rate is tight. At ε=104\varepsilon = 10^{-4} and a million keys, εU10n\varepsilon U \ge 10n needs a universe of 101110^{11}; below that the true floor is measurably under log2(1/ε)\log_2(1/\varepsilon) and a structure is permitted to be smaller than the quoted bound. The row of the table where the formula visibly fails is the one where εU\varepsilon U equals nn exactly — a million-key universe at one per cent accepts ten thousand keys and holds ten thousand real ones, so the accepted set is barely twice SS and the counting argument’s slack has run out.

Two things follow.

The bound as usually quoted has an unstated hypothesis, and it is the one that fails first in the direction people care about. Tightening ε\varepsilon is the standard way to make a filter better, and tightening it is what pushes the deployment out of the regime the floor was derived in. A design that reaches for 10610^{-6} on a modest universe is not merely asking for a lot of bits; it may be asking for a bound that does not apply.

And the direction is the friendly one. The exact floor is always at or below the asymptotic one, so quoting nlog2(1/ε)n\log_2(1/\varepsilon) never claims a structure is impossible when it is merely hard. It over-states the irreducible cost, by an amount that is negligible whenever εU\varepsilon U is a few times nn and is a substantial fraction of a bit when it is not.

Which is the same lesson the floor moves when the question does draws about counting sort, arriving here as a continuous version of it: the problem’s parameters do not merely decide which floor applies, they decide by how much the standard one over-shoots. And it is the second time a filter allowed to be wrong’s arithmetic has turned out to hinge on εU\varepsilon U rather than on UU — the first being that the fill, not the universe, is what the rate is a power of.

What kind of bound this is

It is worth being precise about the logical status, because the site distinguishes carefully between what is proved and what is measured, and this essay’s two numbers have different statuses.

The floor is proved. The counting argument above is complete. It applies to every structure that answers approximate membership with one-sided error at rate ε\varepsilon, including ones nobody has written, and it does not depend on any model of computation beyond the structure having a finite memory whose contents determine its answers. Nothing measurable can refute it, and if a measurement ever appeared to, the conclusion would be that the measurement is wrong.

The 9.59 is measured. log2(1/ε)/ln2\log_2(1/\varepsilon)/\ln 2 is the space a Bloom filter needs at its optimal kk under the standard analysis, and the standard analysis contains approximations whose size has been measured and is a few per cent on random keys and 30% on structured ones. So the filled bar in the figure is a theorem and the outlined bar is a good estimate.

That last calculation is the one to keep, because it shows the floor being used as a measuring instrument rather than as a fact. Take any filter at all, measure its rate, compute log2(1/ε)\log_2(1/\varepsilon), and divide into the space it actually occupies. The answer is how far above optimal that specific built object is, and it takes one measurement and one logarithm.

The same two lines, over three ranges

The gap between the floor and the filter is 1/ln2=1.441/\ln 2 = 1.44, a constant — and a constant is the kind of claim that is worth reading over more than one range.

Bits per element: the floor, and what a Bloom filter needsFor each false-positive rate: the information-theoretic floor log₂(1/ε), which no structure answering approximate membership can get under, and the 1.4427× of it a Bloom filter needs at its optimal k. The overhead is the same factor at every rate — 1/ln 2, or 44% — so it is not something a better choice of parameters removes. It is the price of the particular construction, and it is why the cuckoo and quotient filters exist.bits per elementε = 0.22.3 → 3.3 (+1.0)ε = 0.13.3 → 4.8 (+1.5)ε = 0.054.3 → 6.2 (+1.9)ε = 0.025.6 → 8.1 (+2.5)ε = 0.016.6 → 9.6 (+2.9)floor log₂(1/ε) filled; Bloom's log₂(1/ε)/ln 2 outlined44.3% above the floor at every rate
Fig. 2 The loose end of the range, from one in five to one in a hundred. Both lines are straight in log(1/ε)\log(1/\varepsilon) and the vertical gap between them does not change.

The tight end is the half that matters to anybody sizing a filter for a cache or a router, and it is four orders of magnitude away from the plate above.

Bits per element: the floor, and what a Bloom filter needsFor each false-positive rate: the information-theoretic floor log₂(1/ε), which no structure answering approximate membership can get under, and the 1.4427× of it a Bloom filter needs at its optimal k. The overhead is the same factor at every rate — 1/ln 2, or 44% — so it is not something a better choice of parameters removes. It is the price of the particular construction, and it is why the cuckoo and quotient filters exist.bits per elementε = 0.016.6 → 9.6 (+2.9)ε = 0.0038.4 → 12.1 (+3.7)ε = 0.00110.0 → 14.4 (+4.4)ε = 3e-411.7 → 16.9 (+5.2)ε = 1e-413.3 → 19.2 (+5.9)floor log₂(1/ε) filled; Bloom's log₂(1/ε)/ln 2 outlined44.3% above the floor at every rate
Fig. 3 And the tight end, from one in a hundred to one in ten thousand. The same two lines, the same gap, four orders of magnitude away from the plate above.

And three points spanning the whole of it are enough to read the constant off directly, which is the cheapest form the claim takes.

Bits per element: the floor, and what a Bloom filter needsFor each false-positive rate: the information-theoretic floor log₂(1/ε), which no structure answering approximate membership can get under, and the 1.4427× of it a Bloom filter needs at its optimal k. The overhead is the same factor at every rate — 1/ln 2, or 44% — so it is not something a better choice of parameters removes. It is the price of the particular construction, and it is why the cuckoo and quotient filters exist.bits per elementε = 0.13.3 → 4.8 (+1.5)ε = 0.016.6 → 9.6 (+2.9)ε = 0.00110.0 → 14.4 (+4.4)floor log₂(1/ε) filled; Bloom's log₂(1/ε)/ln 2 outlined44.3% above the floor at every rate
Fig. 4 Three decades, three points, two parallel lines. The gap is 44% at every one of them, which is what a constant factor between two logarithms looks like when both are drawn.
Bits per element: the floor, and what a Bloom filter needsFor each false-positive rate: the information-theoretic floor log₂(1/ε), which no structure answering approximate membership can get under, and the 1.4427× of it a Bloom filter needs at its optimal k. The overhead is the same factor at every rate — 1/ln 2, or 44% — so it is not something a better choice of parameters removes. It is the price of the particular construction, and it is why the cuckoo and quotient filters exist.bits per elementε = 0.51.0 → 1.4 (+0.4)ε = 0.13.3 → 4.8 (+1.5)ε = 0.025.6 → 8.1 (+2.5)ε = 0.0048.0 → 11.5 (+3.5)ε = 8e-410.3 → 14.8 (+4.6)floor log₂(1/ε) filled; Bloom's log₂(1/ε)/ln 2 outlined44.3% above the floor at every rate
Fig. 5 The widest range the machinery draws, spanning both. A floor that is log2(1/ε)\log_2(1/\varepsilon) and a structure that is log2(1/ε)/ln2\log_2(1/\varepsilon)/\ln 2 are parallel lines by construction, and drawing them is how a reader can see that the 44% is a factor rather than a term.

The floors field, now with two axes

This is the fifth distinct floor on the site and the first on a resource other than time, so it is worth setting the collection side by side. The interesting comparison is not the bounds but how close anything gets to them.

bound on best real algorithm
log2(n!)\log_2(n!) comparisons comparison sorting merge sort, ~1.05×
Ω(E)\Omega(E) edge reads graph connectivity any traversal, 1×
nlog2(1/ε)n\log_2(1/\varepsilon) bits approximate membership cuckoo filter, ~1.05×
nlog2(1/ε)n\log_2(1/\varepsilon) bits approximate membership Bloom filter, 1.44×

Three of the four are nearly tight, which is the useful observation. A lower bound that nothing approaches is a statement about the problem; a lower bound that something approaches is a statement about the algorithm, and it converts “is this good?” from a comparison against other implementations into a comparison against what is possible.

Two floors, 8 distinct values among 256Every sort's comparison count on an input drawn from 8 distinct values, on a logarithmic axis, with both floors marked. The right-hand line is log₂(n!) = 1,684 bits, which is the floor every table quotes. The left-hand line is the log of the multinomial — 739 bits — which is the number of outcomes a sort must actually separate, and it is 2.28 times lower. Merge sort sits exactly on the right-hand line and is 2.28 times above the left-hand one.the floor that applieslog₂(n!)Merge sort2.3×1,682Shellsort2.3×1,714Merge sort + cutoff2.6×1,938Heapsort4.2×3,101Quicksort, first6.6×4,887Quicksort, random7.2×5,291Quicksort, median-37.8×5,728Insertion sort18.5×13,644Bubble sort43.1×31,820Selection sort44.2×32,6408 distinct values, n = 256, seededthe two floors are 2.28× apart
Fig. 6 And the precedent for a floor moving when the question is restated. Two hundred and fifty-six values drawn from eight distinct ones have 1,684 bits of permutation entropy and 739 bits of distinguishability — the real floor is 2.28 times lower than the one every table quotes. The membership floor has the same character: log₂(1/ε) is the bound for the problem as stated, and stating a narrower problem moves it.

Using the floor while sizing

The bound has a practical use that is separate from its role as a proof, and it takes one line of arithmetic.

Whenever a filter is specified — 1% false positives on fifty million keys, say — the floor immediately gives the irreducible cost: 50×106×6.64/8=41.550 \times 10^6 \times 6.64 / 8 = 41.5 megabytes. Any structure meeting that specification is at least that large, so if the budget is 30 megabytes the specification is impossible and no amount of implementation cleverness will rescue it. That is worth knowing in the first minute of a design rather than the last.

Then the Bloom number, 59.9 megabytes, says what the standard answer costs, and the ratio between them — 1.44 — is the entire space of improvement available from choosing a different structure. If 60 megabytes is affordable, the conversation is over and a Bloom filter is the right answer because it is the simplest. If 45 is affordable and 60 is not, the 1.44 is exactly the gap a cuckoo filter closes, and the extra complexity is now justified by a number rather than by a preference.

That is the general use of a tight lower bound, and it is the reason this one is more useful than the comparison-sorting floor despite being a weaker-sounding statement. Knowing that sorting cannot beat log2(n!)\log_2(n!) rarely changes what anyone does, because the available sorts are already within a few per cent of it and the choice between them turns on other things entirely. Knowing that membership cannot beat nlog2(1/ε)n\log_2(1/\varepsilon) decides, immediately, whether a proposed budget is feasible and how much a better structure could possibly buy.

What the bound does not cover

Three exclusions, each of which is a real structure the bound does not constrain.

Two-sided error. The argument assumed no false negatives. A structure permitted to be wrong in both directions can be smaller — considerably so, since the accepted set no longer has to contain SS — and that is a different problem with a different floor.

Queries from a known distribution. The bound counts all (Un)\binom{U}{n} sets as equally likely. If the queries are known to concentrate on a small part of the universe, a structure can be sized against that and the counting argument’s premise is gone. This is the same escape as counting sort’s: the floor holds for the problem as stated, and stating a narrower problem moves it.

Structures that can be rebuilt from the keys. A perfect-hash-plus-fingerprint arrangement sits essentially on the floor and needs the whole key set in advance to build the perfect hash. So the honest version of the comparison is “among structures supporting one-at-a-time insertion”, and within that class the 1.05× of the cuckoo and quotient filters is the number to beat.

None of those weakens the bound; each of them names a hypothesis it depends on, which is what a floor is made of. The one it does not depend on is the size of the universe, and that remains the surprising part: the price of approximate membership is set entirely by how often the answer is allowed to be wrong.

What this makes readable

Essays that name this one as a prerequisite.

Named alongside this one

Essays reaching for the same objects. Nobody chose these; they are what the concept index makes visible.

What links here

Every essay whose body links to this one.

The objects this essay names

Each one links to every other essay that touches it.

Approximate membershipBloom filterCounting argumentInformation-theoretic boundLower boundSpace lower bound