Non-empty Bins with Simple Tabulation Hashing

Anders Aamand, Mikkel Thorup

TL;DR

This paper proves that simple tabulation hashing—an incredibly fast and easy-to-implement technique—behaves almost identically to "perfect" fully random hashing when it comes to how many bins are filled. This provides a rigorous theoretical foundation for using simple tabulation in performance-critical applications like Bloom filters and Filter hashing without sacrificing accuracy or reliability.

What Problem Does This Paper Address?

In computer science, we often use the "balls and bins" paradigm: if you throw $m$ items (balls) into $n$ slots (bins) using a hash function, how many slots end up containing at least one item?

Standard data structures like Bloom filters (used for fast membership testing) rely on this. Their design assumes "fully random hashing," where every item is placed completely independently. However, truly random hashing is a theoretical ideal that is impossible to implement efficiently. In practice, we use "realistic" hash functions that are fast but have limited independence.

The challenge is: Does using a simpler, faster hash function break the probabilistic guarantees we rely on? Specifically, if the number of non-empty bins deviates from the ideal, a Bloom filter's false-positive rate might skyrocket for certain "bad" inputs. Anders Aamand and Mikkel Thorup set out to prove that for simple tabulation hashing, this doesn't happen.

Methods

The authors employ advanced probabilistic analysis to study simple tabulation hashing. In this method, a key is broken into several "characters" (e.g., a 32-bit integer treated as four 8-bit characters). Each character is used as an index into a small table of truly random values, and the results are XORed together.

To prove their results, they use:

  • Position Character Ordering: A technique to analyze dependencies by looking at keys character-by-character in a specific order.
  • The "Dummy Ball" Argument: A clever proof construction where they add imaginary "dummy" balls to the bins to simplify the math and account for the slight dependencies inherent in tabulation.
  • Martingale Inequalities: They apply Azuma’s and McDiarmid’s inequalities to show that the number of non-empty bins is "concentrated"—meaning it stays very close to its average value with high probability.

Datasets

Not discussed in the paper. As a theoretical computer science paper, it relies on mathematical proofs and asymptotic analysis rather than empirical testing on specific datasets. The results are intended to hold for any possible input set $X$.

Key Insights and Ideas

  • Closing the Gap: While simple tabulation is only "3-independent" (a technical measure of randomness), the authors show it performs as well as much more complex "highly independent" functions for the non-empty bins problem.
  • Independence isn't Everything: The "aha moment" is that the specific structure of tabulation hashing prevents the kind of "clumping" that would normally ruin the performance of a low-independence hash function.
  • Robustness for Bloom Filters: A major takeaway is that if you use simple tabulation for a Bloom filter, you get the same low false-positive probability as the "perfect" theoretical model, regardless of what data you are hashing.
  • Handling Arbitrary Ranges: They provide a "standard trick" to adapt tabulation (which naturally outputs powers of two) to any range size $n$ without losing these theoretical guarantees.

Key Results

  • Expected Value: The expected number of non-empty bins matches the fully random case to within a very small error term: $|E[|h(X)|] - \mu_0| \leq m^{2-1/c}/n$.
  • Relative Error: For typical parameters, the relative error is negligible, specifically $\tilde{O}(n^{-1/c})$, where $c$ is the number of characters.
  • Concentration: They provide high-probability bounds showing that the number of non-empty bins won't deviate significantly from the mean. For example, the probability of a large deviation $t$ is bounded by $O(\exp(-t^2 / 2m^{2-1/c}))$.
  • Application Success: They demonstrate that in "Filter Hashing" (a multi-layer hashing scheme), simple tabulation achieves the same high occupancy rates as ideal hashing.

Limitations and Future Work

  • Concentration Limits: The authors acknowledge that while concentration is good, it isn't quite as sharp as fully random hashing. They provide a lower bound showing that some slight deviation is inevitable due to the structure of tabulation.
  • Simple vs. Double Tabulation: This paper focuses on simple tabulation. While "double tabulation" offers even stronger independence, it is significantly slower. This work justifies staying with the faster "simple" version for many use cases.
  • Scope: The analysis is specific to the number of non-empty bins. Other metrics, like the maximum number of balls in any single bin ("max load"), require different analyses (though simple tabulation is known to perform well there too).

Summary updated

BibTeX
@inproceedings{aamand2019non,
  author = {Anders Aamand and Mikkel Thorup},
  title = {{Non-empty Bins with Simple Tabulation Hashing}},
  booktitle = {SODA},
  year = {2019},
  doi = {10.1137/1.9781611975482.153},
}
Figure