[论文解读] Perfect Hashing for Data Management Applications
本文提出了一种新颖且可扩展的算法,用于构建最小完美哈希函数(MPHF),其空间使用接近理论下限——每键略多于3比特,同时在十亿规模数据集上具有实际可行性。通过结合理论坚实的方法与内存层次结构优化,该方法在普通PC上用时不足1.5小时即可为超过十亿个URL构建MPHF,相比以往方法在速度上提升了一个数量级,并显著降低了空间使用量。
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$.
研究动机与目标
- 弥合理论最小完美哈希与大规模数据管理实际实现之间的差距。
- 设计一种方法,在不依赖于自由的真正随机哈希函数等不切实际假设的前提下,实现接近最优的空间使用(接近1.4427n比特)。
- 实现在普通硬件上对规模达十亿个键的数据集高效构建MPHF。
- 提供一种可证明正确的外部内存算法,在保持理论保证的同时适用于真实工作负载。
- 在空间效率和构造速度方面超越现有实用方法,适用于大规模键集。
提出的方法
- 内部算法使用两个通用哈希函数(来自Thorup家族)模拟真正随机函数,通过无环随机图结构实现完美哈希函数的构建。
- 外部算法将理想化的随机函数替换为使用查找表实现的可证明优良的替代方案,确保对任意键集的正确性。
- 通过组织数据访问以最小化缓存未命中和I/O操作,利用内存层次结构提升大规模数据集上的性能。
- 外部算法的启发式变体使用Jenkins的快速伪随机哈希函数以减少评估时间,以牺牲理论保证为代价换取速度提升。
- 该算法设计用于生成值域为{0, ..., n-1}(最小)或{0, ..., 2n-1}的MPHF,后者可将空间降低至每键略多于2比特。
- 构造过程针对外部内存进行了优化,采用多阶段方法对键集进行分区,并在磁盘与主内存之间高效处理。
实验结果
研究问题
- RQ1能否设计一种完美哈希方案,既在理论上理解透彻,又在大规模数据管理应用中具备实际效率?
- RQ2对于较大的n,能否构建出空间使用接近理论下限1.4427n比特的最小完美哈希函数?
- RQ3能否使MPHF的构建在普通硬件上对超过十亿个键的数据集具有实用性?
- RQ4如何通过内存层次结构感知提升完美哈希构造算法的性能?
- RQ5能否设计一种可证明正确的外部内存算法,避免以往依赖不切实际假设的方法的缺陷?
主要发现
- 外部算法在普通PC上仅用时一个多小时,即为超过十亿个URL构建了最小完美哈希函数,相比以往实用方法实现了数量级的速度提升。
- 该方法在最小完美哈希函数中实现每键略多于3比特的空间使用,当使用{0, ..., 2n-1}范围时,空间使用降至每键略多于2比特。
- 当使用{0, ..., 2n-1}范围时,生成的MPHF存储空间不足324 MB,可容纳于一个32位字中。
- 外部算法的启发式变体将评估时间减少至以往方法的两倍以内,同时保持相近的空间效率。
- 该外部算法是首个在不依赖理想化假设的前提下,将可证明正确性与十亿规模键集的实用可扩展性相结合的方法。
- 该算法以LGPL许可证公开发布,可被用于数据管理与信息检索系统中。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。