论文标题

重新访问的无锁锁

Lock-Free Locks Revisited

论文作者

Ben-David, Naama, Blelloch, Guy E., Wei, Yuanhao

论文摘要

本文提出了一种基于帮助的新的且实用的方法,可以根据帮助,该方法使用户可以使用细粒度锁来编写代码,但以无锁的方式运行它。 尽管过去建议使用无锁的锁,但它们被广泛认为是不切实际的,有一些关键的局限性,据我们所知,从未实施过。该论文介绍了一些关键技术,这些技术使无锁的锁实用,更通用。最重要的技术是一种掌握势力的方法 - 即制作多次运行的代码看起来好像运行一次。该想法基于在运行相同受保护的代码的过程中使用共享日志。重要的是,该方法可以是基于库的,如果对标准代码进行任何更改,则几乎不需要使用内存操作(加载,商店,ll/sc,分配,免费)的IDEMPOTENT版本。 我们根据这些想法实施了一个名为Flock的C ++库。羊群允许基于锁定的数据结构以无锁或阻塞(传统锁)模式运行。我们用羊群实施了各种基于树和列表的数据结构,并比较了各种工作量下的无锁和阻塞模式的性能。在几乎所有工作负载下,无锁模式几乎与阻止模式一样快,并且当线程被超额订阅时(线程多于处理器),速度要快得多。我们还与几种现有的基于锁定的替代方案进行了比较。

This paper presents a new and practical approach to lock-free locks based on helping, which allows the user to write code using fine-grained locks, but run it in a lock-free manner. Although lock-free locks have been suggested in the past, they are widely viewed as impractical, have some key limitations, and, as far as we know, have never been implemented. The paper presents some key techniques that make lock-free locks practical and more general. The most important technique is an approach to idempotence -- i.e. making code that runs multiple times appear as if it ran once. The idea is based on using a shared log among processes running the same protected code. Importantly, the approach can be library based, requiring very little if any change to standard code -- code just needs to use the idempotent versions of memory operations (load, store, LL/SC, allocation, free). We have implemented a C++ library called Flock based on the ideas. Flock allows lock-based data structures to run in either lock-free or blocking (traditional locks) mode. We implemented a variety of tree and list-based data structures with Flock and compare the performance of the lock-free and blocking modes under a variety of workloads. The lock-free mode is almost as fast as blocking mode under almost all workloads, and significantly faster when threads are oversubscribed (more threads than processors). We also compare with several existing lock-based and lock-free alternatives.

扫码加入交流群

加入微信交流群

微信交流群二维码

扫码加入学术交流群,获取更多资源