[Paper Review] Perfect Hashing for Data Management Applications
This paper presents a novel, scalable algorithm for constructing minimal perfect hash functions (MPHFs) that achieves near-theoretical space bounds—slightly over 3 bits per key—while being practical for billion-scale datasets. By combining a theoretically sound scheme with memory hierarchy optimization, the method constructs MPHFs for over one billion URLs in under 1.5 hours on a commodity PC, outperforming prior methods by an order of magnitude in speed and significantly reducing space usage.
Perfect hash functions can potentially be used to compress data in connection with a variety of data management tasks. Though there has been considerable work on how to construct good perfect hash functions, there is a gap between theory and practice among all previous methods on minimal perfect hashing. On one side, there are good theoretical results without experimentally proven practicality for large key sets. On the other side, there are the theoretically analyzed time and space usage algorithms that assume that truly random hash functions are available for free, which is an unrealistic assumption. In this paper we attempt to bridge this gap between theory and practice, using a number of techniques from the literature to obtain a novel scheme that is theoretically well-understood and at the same time achieves an order-of-magnitude increase in performance compared to previous ``practical'' methods. This improvement comes from a combination of a novel, theoretically optimal perfect hashing scheme that greatly simplifies previous methods, and the fact that our algorithm is designed to make good use of the memory hierarchy. We demonstrate the scalability of our algorithm by considering a set of over one billion URLs from the World Wide Web of average length 64, for which we construct a minimal perfect hash function on a commodity PC in a little more than 1 hour. Our scheme produces minimal perfect hash functions using slightly more than 3 bits per key. For perfect hash functions in the range $\{0,...,2n-1\}$ the space usage drops to just over 2 bits per key (i.e., one bit more than optimal for representing the key). This is significantly below of what has been achieved previously for very large values of $n$.
Motivation & Objective
- To bridge the gap between theoretical minimal perfect hashing and practical implementation for large-scale data management.
- To design a method that achieves near-optimal space usage (close to 1.4427n bits) without relying on unrealistic assumptions like free truly random hash functions.
- To enable efficient construction of MPHFs for datasets of size up to one billion keys on commodity hardware.
- To provide a provably correct external-memory algorithm that maintains theoretical guarantees while being practical for real-world workloads.
- To outperform existing practical methods in both space efficiency and construction speed for large key sets.
Proposed method
- The internal algorithm uses two universal hash functions (from Thorup's family) to simulate truly random functions, enabling construction of a perfect hash function via an acyclic random graph structure.
- The external algorithm replaces the idealized random functions with a provably good implementation using lookup tables, ensuring correctness for any key set.
- The method leverages the memory hierarchy by organizing data access to minimize cache misses and I/O operations, improving performance on large datasets.
- A heuristic variant of the external algorithm uses Jenkins' fast pseudo-random hash function to reduce evaluation time, trading off theoretical guarantees for speed.
- The algorithm is designed to produce MPHFs with values in {0, ..., n-1} (minimal) or {0, ..., 2n-1}, with the latter reducing space to just over 2 bits per key.
- The construction process is optimized for external memory, using a multi-phase approach that partitions the key set and processes it efficiently across disk and main memory.
Experimental results
Research questions
- RQ1Can a perfect hashing scheme be both theoretically well-understood and practically efficient for large-scale data management applications?
- RQ2Is it possible to construct minimal perfect hash functions with space usage close to the theoretical lower bound of 1.4427n bits for large n?
- RQ3Can the construction of MPHFs be made practical for datasets of over one billion keys on commodity hardware?
- RQ4How can memory hierarchy awareness improve the performance of perfect hashing construction algorithms?
- RQ5Can a provably correct external-memory algorithm be designed that avoids the pitfalls of previous methods relying on unrealistic assumptions?
Key findings
- The external algorithm constructs a minimal perfect hash function for over one billion URLs in just over one hour on a commodity PC, representing an order-of-magnitude speedup over previous practical methods.
- The method achieves a space usage of slightly more than 3 bits per key for minimal perfect hash functions, and just over 2 bits per key when using the range {0, ..., 2n-1}.
- The resulting MPHFs require less than 324 MB of storage when using the {0, ..., 2n-1} range, fitting within a 32-bit word.
- The heuristic variant of the external algorithm reduces evaluation time to less than twice that of previous methods, while maintaining similar space efficiency.
- The external algorithm is the first to combine provable correctness with practical scalability for billion-scale key sets, without relying on idealized assumptions.
- The algorithm is publicly available under the LGPL license, enabling adoption in data management and information retrieval systems.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.