arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 1712.01044cs.DC
收藏

为无锁数据结构回收内存:必须有更好的方法

Reclaiming memory for lock-free data structures: there has to be a better way

Trevor Brown

摘要:

基于锁的数据结构的存储器回收通常是容易的。然而,这对于无锁数据结构来说是一个重大的挑战。诸如垃圾回收之类的自动技术效率低下或使用锁,而非自动技术要么开销很高,要么不适用于许多数据结构。例如,当危险指针(最常见的非自动技术之一)应用于许多无锁数据结构时,可能会出现一些微妙的问题。基于纪元的回收(EBR)是迄今为止最有效的非自动技术,它允许未回收对象的数量无限增长,因为一个崩溃的进程可以阻止所有其他进程回收内存。我们开发了一种更有效的分布式EBR变体来解决这个问题。它基于许多操作系统(如Linux和UNIX)提供的信令。我们的新方案需要$O(1)$摊销步骤的数据结构和$O(1)$步骤在最坏的情况下,每次从数据结构中删除一个对象。在任何时候,$O(mn^2)$对象都在等待被释放,其中$n$是进程的数量,$m$是大多数数据结构的小常量。实验结果表明,在多线程、多操作混合和多争用的情况下,该算法的开销平均为10%,最差为28%.我们的计划也优于一个高度调整的危险指针的平均75%的实现。通常,内存回收被紧密地编织到无锁数据结构代码中。为了提高模块性和方便比较不同的内存回收方案,我们还引入了一个高度灵活的抽象。它允许程序员通过改变一行代码,轻松地交换回收、对象池、分配和释放的方案,几乎没有开销。

英文摘要:

Memory reclamation for lock-based data structures is typically easy. However, it is a significant challenge for lock-free data structures. Automatic techniques such as garbage collection are inefficient or use locks, and non-automatic techniques either have high overhead, or do not work for many data structures. For example, subtle problems can arise when hazard pointers, one of the most common non-automatic techniques, are applied to many lock-free data structures. Epoch based reclamation (EBR), which is by far the most efficient non-automatic technique, allows the number of unreclaimed objects to grow without bound, because one crashed process can prevent all other processes from reclaiming memory. We develop a more efficient, distributed variant of EBR that solves this problem. It is based on signaling, which is provided by many operating systems, such as Linux and UNIX. Our new scheme takes $O(1)$ amortized steps per high-level operation on the data structure and $O(1)$ steps in the worst case each time an object is removed from the data structure. At any point, $O(mn^2)$ objects are waiting to be freed, where $n$ is the number of processes and $m$ is a small constant for most data structures. Experiments show that our scheme has very low overhead: on average 10\%, and at worst 28\%, for a balanced binary search tree over many thread counts, operation mixes and contention levels. Our scheme also outperforms a highly tuned implementation of hazard pointers by an average of 75\%. Typically, memory reclamation is tightly woven into lock-free data structure code. To improve modularity and facilitate the comparison of different memory reclamation schemes, we also introduce a highly flexible abstraction. It allows a programmer to easily interchange schemes for reclamation, object pooling, allocation and deallocation with virtually no overhead, by changing a single line of code.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑