轻松实现并发数据结构(扩展版)
Concurrent Data Structures Made Easy (Extended Version)
AI总结:
本文提出OCaml库OBatcher,通过轻量级隐式批处理设计和顺序结构转换策略,简化批处理并行并发数据结构的设计与使用,并在大型异步工作负载中展现出优于锁实现的可扩展吞吐量。
摘要:
设计高效的线程安全并发数据结构是一种在实现复杂度和性能之间保持平衡的行为。基于锁的并发数据结构相对容易从其顺序对应物派生并证明其线程安全,但即使在轻量级多线程工作负载下也会出现吞吐量差的问题。同时,无锁并发结构允许高吞吐量,但众所周知很难正确实现,并且需要仔细推理以正式确立其正确性。\n我们探索了一种基于批处理并行性的解决方案,这是一种通过一个简单洞察来设计并发数据结构的方法:并行处理一批预先已知的操作,比为任意异步请求流优化性能更容易。遗憾的是,批处理并行结构并未在实际中得到广泛采用,原因在于(i)必须构建多线程程序以显式分组操作的不便性,以及(ii)缺乏一种系统化方法来像基于锁的结构那样简单地实现批处理并行结构。\n我们提出了 OBatcher——一个 OCaml 库,它简化了批处理结构的设计、实现和使用。它通过建议一种建立在通用异步编程机制之上的新型轻量级隐式批处理设计来解决第一个挑战(如何使用)。第二个挑战(如何实现)则通过识别一系列将常见顺序结构转换为高效批处理并行结构的策略来解决。我们用一组多样化的基准测试展示了 OBatcher。我们对所有实现在大型异步工作负载上的评估表明:(a)它们始终优于相应的粗粒度基于锁的实现,并且(b)它们的吞吐量随处理器数量合理扩展。
英文摘要:
Design of an efficient thread-safe concurrent data structure is a balancing act between its implementation complexity and performance. Lock-based concurrent data structures, which are relatively easy to derive from their sequential counterparts and to prove thread-safe, suffer from poor throughput under even light multi-threaded workload. At the same time, lock-free concurrent structures allow for high throughput, but are notoriously difficult to get right and require careful reasoning to formally establish their correctness. We explore a solution to this conundrum based on batch parallelism, an approach for designing concurrent data structures via a simple insight: efficiently processing a batch of a priori known operations in parallel is easier than optimising performance for a stream of arbitrary asynchronous requests. Alas, batch-parallel structures have not seen wide practical adoption due to (i) the inconvenience of having to structure multi-threaded programs to explicitly group operations and (ii) the lack of a systematic methodology to implement batch-parallel structures as simply as lock-based ones. We present OBatcher-an OCaml library that streamlines the design, implementation, and usage of batch-parallel structures. It solves the first challenge (how to use) by suggesting a new lightweight implicit batching design that is built on top of generic asynchronous programming mechanisms. The second challenge (how to implement) is addressed by identifying a family of strategies for converting common sequential structures into efficient batch-parallel ones. We showcase OBatcher with a diverse set of benchmarks. Our evaluation of all the implementations on large asynchronous workloads shows that (a) they consistently outperform the corresponding coarse-grained lock-based implementations and that (b) their throughput scales reasonably with the number of processors.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。