Haskell中自适应无锁数据结构:一种通用的并发实现交换方法
Adaptive Lock-Free Data Structures in Haskell: A General Method for Concurrent Implementation Swapping
摘要:
实现高级语言的一个关键部分是提供内置和默认的数据结构。然而,选择好的违约是困难的。可变数据结构的工作负载事先是未知的,并且它可以在其生命周期内转移-例如,在读重和写重之间,或者从多线程的严重争用到单线程或低频率使用。一种想法是自适应地切换实现,但是在运行时切换并发数据结构的实现是不平凡的。执行转换需要数据结构内容的并发快照,这通常需要在数据结构的设计中进行特殊工程。然而,在本文中,我们确定和形式化的无锁算法的相关属性。也就是说,锁自由度足以保证以任意顺序冻结存储器位置将导致有效的快照。几种函数式语言具有冻结和解冻的数据结构,在可变和不可变之间转换,例如Haskell vectors和Clojure transients,但这些仅支持单线程编写器。我们推广这种方法来增强任意无锁数据结构的能力,逐渐冻结,并有选择地过渡到一个新的表示。这种扩充不需要更改数据结构的算法或代码,只需要将可变引用的数据类型替换为可冻结变量。在本文中,我们提出了一个算法提升平原自适应数据,并证明了由此产生的混合数据结构本身是无锁的,线性化,并模拟原来的。我们还进行了经验的情况下,加热和冷却并发地图的研究。
英文摘要:
A key part of implementing high-level languages is providing built-in and default data structures. Yet selecting good defaults is hard. A mutable data structure's workload is not known in advance, and it may shift over its lifetime - e.g., between read-heavy and write-heavy, or from heavy contention by multiple threads to single-threaded or low-frequency use. One idea is to switch implementations adaptively, but it is nontrivial to switch the implementation of a concurrent data structure at runtime. Performing the transition requires a concurrent snapshot of data structure contents, which normally demands special engineering in the data structure's design. However, in this paper we identify and formalize an relevant property of lock-free algorithms. Namely, lock-freedom is sufficient to guarantee that freezing memory locations in an arbitrary order will result in a valid snapshot. Several functional languages have data structures that freeze and thaw, transitioning between mutable and immutable, such as Haskell vectors and Clojure transients, but these enable only single-threaded writers. We generalize this approach to augment an arbitrary lock-free data structure with the ability to gradually freeze and optionally transition to a new representation. This augmentation doesn't require changing the algorithm or code for the data structure, only replacing its datatype for mutable references with a freezable variant. In this paper, we present an algorithm for lifting plain to adaptive data and prove that the resulting hybrid data structure is itself lock-free, linearizable, and simulates the original. We also perform an empirical case study in the context of heating up and cooling down concurrent maps.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。