[论文解读] Fast and Simple Compact Hashing via Bucketing
本文提出了一种紧凑哈希表,结合了分离链接(separate chaining)与紧凑哈希(compact hashing),在不存储位移数据的情况下实现了高内存效率和快速插入。通过使用动态数组作为桶,并将键与值分离存储,该方法在保持快速构建的同时减少了内存开销,在现代架构上处理大规模附属数据时,其空间利用率和插入速度优于以往的紧凑哈希表。
Compact hash tables store a set S of n key-value pairs, where the keys are from the universe U = {0,…,u-1}, and the values are v-bit integers, in close to B(u, n) + nv bits of space, where {b(u, n)} = log₂ binom(u,n) is the information-theoretic lower bound for representing the set of keys in S, and support operations insert, delete and lookup on S. Compact hash tables have received significant attention in recent years, and approaches dating back to Cleary [IEEE T. Comput, 1984], as well as more recent ones have been implemented and used in a number of applications. However, the wins on space usage of these approaches are outweighed by their slowness relative to conventional hash tables. In this paper, we demonstrate that compact hash tables based upon a simple idea of bucketing practically outperform existing compact hash table implementations in terms of memory usage and construction time, and existing fast hash table implementations in terms of memory usage (and sometimes also in terms of construction time). A related notion is that of a compact Hash ID map, which stores a set Ŝ of n keys from U, and implicitly associates each key in Ŝ with a unique value (its ID), chosen by the data structure itself, which is an integer of magnitude O(n), and supports inserts and lookups on Ŝ, while using close to B(u,n) bits. One of our approaches is suitable for use as a compact Hash ID map.
研究动机与目标
- 解决传统哈希表内存效率低下的问题,这些表要么浪费空间(开放寻址),要么使用额外指针(分离链接)。
- 消除紧凑哈希中对位移信息的需求,而位移信息通常在开放寻址方案中用于重建键。
- 设计一种紧凑哈希表,在构建过程中保持高性能的同时最小化内存占用。
- 证明当针对内存和现代缓存层次结构进行优化时,分离链接在紧凑哈希中可以成为一种具有竞争力的方法。
提出的方法
- 使用分离链接,以动态数组作为桶,将键和值分别存储在大小相等的独立数组中,以提升缓存局部性。
- 应用一个单射函数将键映射为商-余数对,其中商存储在哈希表中,余数则从键中导出。
- 在桶大小达到阈值 bmax 时触发表的重新分配,将桶的数量加倍,并重新分配元素。
- 采用两阶段构建过程:首先将元素插入桶中,直到达到 bmax;然后创建一个桶数量加倍的新表,并迁移元素。
- 通过将桶对齐到缓存行,并将键数组与值数组分离,优化内存布局,以在查找时提升数据局部性。
- 利用位并行操作加速紧凑表示中商的查找,通过类似SIMD的位操作实现对多个商的高效比较。
实验结果
研究问题
- RQ1在紧凑哈希中,是否可以实现分离链接的内存效率,而无需像开放寻址方案那样存储位移数据?
- RQ2基于分离链接的紧凑哈希表在插入速度和内存使用方面,与现有紧凑哈希表相比表现如何?
- RQ3在动态重分配中,平衡内存开销与性能的最优桶大小阈值 bmax 是多少?
- RQ4将键与值分别存储在独立数组中,是否能提升紧凑哈希表的缓存效率并减少查找时间?
- RQ5位并行技术在紧凑表示的哈希表中,能在多大程度上加速商的查找?
主要发现
- 在现代计算机架构上存储足够大的卫星数据时,该方法的插入性能优于所有已知的紧凑哈希表,或在空间使用上更优。
- 与现有紧凑哈希表相比,该方法在构建过程中实现了更低的内存占用,尤其得益于减少了指针和元数据的开销。
- 使用独立的键和值数组改善了数据局部性,从而提升了大值和小键场景下的性能。
- 该方法消除了对位移信息的需求,简化了数据结构并降低了复杂度。
- 通过整批迁移桶的方式逐步进行重分配,避免了传统动态数组在重分配期间为预留 3m 个元素而造成的内存峰值。
- 当元素数量足够大,足以抵消独立键和值数组的开销时,该方法尤其有效,适用于具有大卫星数据的应用。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。