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.
翻译:本文介绍了一种基于帮助的无锁的新的实用方法,它让用户能够使用细细的加成锁来写代码,但以无锁的方式运行。虽然过去曾提出过无锁的锁,但被广泛认为是不切实际的,有一些关键的局限性,而且,据我们所知,从未实施过。本文介绍了一些使无锁的锁切实可行和更加普通的关键技术。最重要的技术是“一罪不二审”的方法,即使代码多次运行的代码显示为“一罪不二审 ” 。这个方法基于的是使用同一受保护的代码的流程之间的共享日志。重要的是,这个方法可以以图书馆为基础,只要对标准代码作任何改动,就几乎是不切实际的,代码只需使用理想的版本的存储操作(load、存储、LL/SC、分配、基于理念的),我们实施了名为“Flock”的C++图书馆。Flock使基于锁的数据结构可以像“一罪不二审”一样运行。我们把基于锁的数据结构与“传统锁”模式一起运行。在“一无锁”或“一罪不二审”模式下,我们用几乎是“一不二审的“一不二审”的“一不休的“一不休的”的“一不休之行”的“一行”模式,我们用“一行”将“一不休之行”将“一行”将“一行”将“一行”的“一行”的“一行的”将“一行”的“一行的”的“一行的”的”将“一行的”将“一行的”的“一行的”模式下“一行的”将“一行的“一行的“一行”将“一行的“一行”模式,在“一行的”将“一行的”将“一行的”模式下“一行”将“一行的”和“一行的“一行的“一行的“一行的“一行的“一行”将“一行的“一行”将“一行”将“一行”将“一行”将“一行”与“一行的“一行的“一行的“一行的“一行的”进行。我们