Abstract
Minimal perfect hashing maps a static set of $n$ keys to exactly $n$ distinct integers without collisions, approaching the information-theoretic lower bound of approximately 1.44 bits per key. This survey categorizes modern techniques from the last 25 years into retrieval, brute-force, and fingerprinting families. By providing a massive empirical benchmark, the authors offer a guide for practitioners to navigate the trade-offs between construction time, query speed, and memory consumption.
Introduction
Standard hash tables inevitably suffer from collisions, necessitating extra memory and logic—such as linked lists or open addressing—to resolve them. However, for static datasets where keys do not change after the table is built (e.g., dictionaries, static databases, or bioinformatics k-mers), one can precompute a "perfect" hash function that guarantees zero collisions. When this function maps $n$ keys to exactly $n$ slots (integers $0$ to $n-1$), it is termed a Minimal Perfect Hash Function (MPHF).
The primary challenge lies in the representation of this function. Information theory dictates a lower bound of $\approx 1.443$ bits per key. Modern research focuses on a tri-fold optimization: approaching this theoretical limit while minimizing both construction and query times.
Taxonomy of Modern MPHFs
The authors systematically categorize modern MPHF constructions into three main families based on their underlying mechanics.
- Perfect Hashing through Retrieval: These methods treat hashing as solving a massive system of linear equations on hypergraphs. A small "retrieval" data structure stores which candidate hash function yields a collision-free slot for a given key.
- Perfect Hashing through Brute-Force: While direct brute-forcing is computationally expensive, modern "divide and conquer" strategies make it practical.
- Bucket Placement (e.g., PTHash, PtrHash, PHast) groups keys into small buckets and searches for a "seed" value to place each bucket without collisions.
- Recursive Splitting (e.g., RecSplit) recursively partitions keys into smaller sets until brute-forcing a perfect hash function becomes trivial.
- Perfect Hashing through Fingerprinting: Methods like BBHash and FiPS assign small fingerprints to keys. If fingerprints collide, the algorithm builds additional layers to resolve them recursively.
Experimental Methodology
To evaluate these algorithms, the authors benchmarked them using randomly generated string keys (10–50 characters). The datasets scaled from 1 million to 1.28 billion keys, testing both single-threaded performance and multi-threaded scalability.
Key Insights and Performance Trade-offs
The survey reveals several critical findings for practitioners:
- The Space-Time Pareto Front: There is a stark trade-off between hash function size and execution speed. The paper provides "dominance maps" to help select the optimal algorithm for specific constraints.
- Memory Access Bottlenecks: Query throughput is primarily limited by CPU cache misses. The fastest algorithms, such as
PHastandPtrHash, are optimized to require exactly one memory access per query. - Approaching Theoretical Limits: Modern methods are now tantalizingly close to the mathematical floor. The
CONSENSUS-RSmethod achieves 1.444 bits/key, within 0.1% of the theoretical lower bound. - Construction Efficiency: For massive datasets, construction speed is vital.
FiPSandPtrHashoffer rapid construction and scale effectively across multiple CPU threads.
Conclusion and Future Outlook
While space-efficient methods like CONSENSUS or RecSplit currently suffer from slower query times due to tree traversal or variable-length decoding, there is no fundamental mathematical barrier preventing high space efficiency and high query speed from coexisting. Future work aims to bridge this gap, potentially reaching the space lower bound while maintaining single-memory-access query speeds. Additionally, GPU-accelerated construction remains a promising frontier for handling even larger datasets.
Summary updated