线性探测再访:墓碑标志着主聚类的死亡
Linear Probing Revisited: Tombstones Mark the Death of Primary Clustering
摘要:
线性探测于1954年首次引入,是计算机科学中最古老的数据结构之一,由于其无与伦比的数据局部性,它仍然是实践中最快的哈希表之一。然而,人们普遍认为并教导,线性探测不应在高负载因子下使用;这是因为主聚类效应导致在负载因子$1 - 1 /x$下的插入花费预期的时间$Θ(x^2)$(而不是理想的$Θ(x)$)。主聚类的危险,首先由Knuth在1963年发现,已经被教导给几代计算机科学家,并影响了许多广泛使用的哈希表的设计。我们表明,主要集群是不是一个定局。我们证明,小的设计决策,在如何删除实施插入的渐近性能有显着的影响,因此,即使一个哈希表连续运行在一个负载因子$1 - Θ(1/x)$,每次操作的预期摊销成本是$\tilde{O}(x)$。这是因为由删除创建的墓碑实际上会导致对抗主聚类的反聚类效应。我们还提出了一种新的线性探测(我们称之为墓地哈希),完全消除了主集群上的\emph{any}操作序列:如果,当一个操作被执行,当前的负载因子是$1 - 1/x$的一些$x$,那么操作的预期成本是$O(x)$。一个推论是,在数据块大小为$B$的外部内存模型中,墓地哈希提供了以下显著的保证:在任何满足$x = o(B)$的负载因子$1 - 1/x$,墓地哈希实现了每次操作的$1 + o(1)$预期块传输。过去的外部存储器哈希表只能在块大小$B$至少为$Ω(x^2)$时提供$1 + o(1)$保证。
英文摘要:
First introduced in 1954, linear probing is one of the oldest data structures in computer science, and due to its unrivaled data locality, it continues to be one of the fastest hash tables in practice. It is widely believed and taught, however, that linear probing should never be used at high load factors; this is because primary-clustering effects cause insertions at load factor $1 - 1 /x$ to take expected time $Θ(x^2)$ (rather than the ideal $Θ(x)$). The dangers of primary clustering, first discovered by Knuth in 1963, have been taught to generations of computer scientists, and have influenced the design of some of many widely used hash tables. We show that primary clustering is not a foregone conclusion. We demonstrate that small design decisions in how deletions are implemented have dramatic effects on the asymptotic performance of insertions, so that, even if a hash table operates continuously at a load factor $1 - Θ(1/x)$, the expected amortized cost per operation is $\tilde{O}(x)$. This is because tombstones created by deletions actually cause an anti-clustering effect that combats primary clustering. We also present a new variant of linear probing (which we call graveyard hashing) that completely eliminates primary clustering on \emph{any} sequence of operations: if, when an operation is performed, the current load factor is $1 - 1/x$ for some $x$, then the expected cost of the operation is $O(x)$. One corollary is that, in the external-memory model with a data blocks of size $B$, graveyard hashing offers the following remarkable guarantee: at any load factor $1 - 1/x$ satisfying $x = o(B)$, graveyard hashing achieves $1 + o(1)$ expected block transfers per operation. Past external-memory hash tables have only been able to offer a $1 + o(1)$ guarantee when the block size $B$ is at least $Ω(x^2)$.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。