Hash tables are ubiquitous, and the choice of hash function, which maps a key to a bucket, is key to their performance. We argue that the predominant approach of fixing the hash function for the lifetime of the hash table is suboptimal and propose adapting it to the current set of keys. In the prevailing view, good hash functions spread the keys ``randomly'' and are fast to evaluate. General-purpose ones (e.g. Murmur) are designed to do both while remaining agnostic to the distribution of the keys, which limits their bucketing ability and wastes computation. When these shortcomings are recognized, one may specify a hash function more tailored to some assumed key distribution, but doing so almost always introduces an unbounded risk in case this assumption does not bear out in practice. At the other, fully key-aware end of the spectrum, Perfect Hashing algorithms can discover hash functions to bucket a given set of keys optimally, but they are costly to run and require the keys to be known and fixed ahead of time. Our main conceptual contribution is that adapting the hash table's hash function to the keys online is necessary for the best performance, as adaptivity allows for better bucketing of keys \emph{and} faster hash functions. We instantiate the idea of online adaptation with minimal overhead and no change to the hash table API. The experiments show that the adaptive approach marries the common-case performance of weak hash functions with the robustness of general-purpose ones.


翻译:哈希表无处不在,而将键映射到桶的哈希函数选择对其性能至关重要。我们认为,在哈希表生命周期内固定哈希函数的主流方法并非最优,并建议根据当前键集对其进行自适应调整。主流观点认为,良好的哈希函数应“随机”分散键值且求值迅速。通用哈希函数(如Murmur)旨在兼顾两者,同时不依赖于键的分布,这限制了其分桶能力并造成计算浪费。当认识到这些不足时,人们可能会针对某些假设的键分布设计更专用的哈希函数,但若假设在实践中不成立,这种做法几乎总会引入无限制的风险。在完全感知键谱的另一极端,完美哈希算法虽能发现最优分桶给定键集的哈希函数,但运行成本高昂且要求键集预先已知并固定。我们的核心理论贡献在于:在线调整哈希表的哈希函数以适应键集是实现最佳性能的必要条件,因为自适应性既能提升键的分桶效率,又能加速哈希函数求值。我们以最小开销且不改变哈希表API的方式实现了在线自适应机制。实验表明,自适应方法融合了弱哈希函数的常见场景性能与通用哈希函数的鲁棒性。

0
下载
关闭预览

相关内容

专知会员服务
19+阅读 · 2021年5月16日
【CVPR2020】跨模态哈希的无监督知识蒸馏
专知会员服务
61+阅读 · 2020年6月25日
专知会员服务
50+阅读 · 2020年6月14日
概述自动机器学习(AutoML)
人工智能学家
19+阅读 · 2019年8月11日
激活函数还是有一点意思的!
计算机视觉战队
12+阅读 · 2019年6月28日
Github项目推荐 | DeepHash - 深度学习哈希开源库
AI研习社
27+阅读 · 2019年4月30日
干货 | 深入理解深度学习中的激活函数
计算机视觉life
16+阅读 · 2019年1月29日
详解常见的损失函数
七月在线实验室
20+阅读 · 2018年7月12日
基于二进制哈希编码快速学习的快速图像检索
极市平台
12+阅读 · 2018年5月17日
最新|深度离散哈希算法,可用于图像检索!
全球人工智能
14+阅读 · 2017年12月15日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
Modern Minimal Perfect Hashing: A Survey
Arxiv
0+阅读 · 2月5日
Arxiv
0+阅读 · 1月13日
VIP会员
相关资讯
概述自动机器学习(AutoML)
人工智能学家
19+阅读 · 2019年8月11日
激活函数还是有一点意思的!
计算机视觉战队
12+阅读 · 2019年6月28日
Github项目推荐 | DeepHash - 深度学习哈希开源库
AI研习社
27+阅读 · 2019年4月30日
干货 | 深入理解深度学习中的激活函数
计算机视觉life
16+阅读 · 2019年1月29日
详解常见的损失函数
七月在线实验室
20+阅读 · 2018年7月12日
基于二进制哈希编码快速学习的快速图像检索
极市平台
12+阅读 · 2018年5月17日
最新|深度离散哈希算法,可用于图像检索!
全球人工智能
14+阅读 · 2017年12月15日
相关基金
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员