Skip to main content
QUICK REVIEW

[论文解读] BRAVO—Biased Locking for Reader-Writer Locks

David Dice, Alex Kogan|arXiv (Cornell University)|Oct 3, 2018
Parallel Computing and Optimization Techniques被引用 1
一句话总结

BRAVO 是一种轻量级转换,通过增加两个整数字段,增强现有读写锁,利用共享的、NUMA 友好的可见读者表实现可扩展的读者并发。通过哈希线程身份以将读者存在感分布到表中,BRAVO 减少了缓存一致性流量并保持了紧凑的锁大小,在读取主导的工作负载下实现了高可扩展性,且内存开销极小。

ABSTRACT

Designers of modern reader-writer locks confront a difficult trade-off related to scalability. Locks that have a compact memory representation for active readers will typically suffer under high intensity read-dominated workloads when the reader indicator' state is updated frequently by a diverse set of threads, causing cache invalidation and coherence traffic. Other designs, such as cohort reader-writer locks, use distributed indicators, one per NUMA node. This improves reader-reader scalability, but also increases the size of each lock instance. We propose a simple transformation BRAVO, that augments any existing reader-writer lock, adding just two integer fields to the lock instance. Readers make their presence known to writers by hashing their thread's identity with the lock address, forming an index into a visible readers table. Readers attempt to install the lock address into that element in the table, making their existence known to potential writers. All locks and threads in an address space can share the visible readers table. Updates by readers tend to be diffused over the table, resulting in a NUMA-friendly design. Crucially, readers of the same lock tend to write to different locations in the array, reducing coherence traffic. Specifically, BRAVO allows a simple compact lock to be augmented so as to provide scalable concurrent reading but with only a modest increase in footprint.

研究动机与目标

  • 解决在高并发、读取主导的工作负载下,由于读者状态更新频繁导致缓存行失效而引发的读写锁可扩展性瓶颈。
  • 克服传统锁中紧凑内存表示与读者-读者可扩展性之间的权衡。
  • 使现有读写锁在并发读取下实现高效可扩展性,同时显著减少锁大小的增加。
  • 通过使用线程身份哈希将读者存在感更新分布到共享表中,最小化一致性流量。
  • 设计一种简单且与现有锁实现兼容的解决方案,仅需增加两个额外的整数字段。

提出的方法

  • 将任意现有读写锁扩展为增加两个整数字段:锁特定索引和读者计数。
  • 使用一个全局共享的可见读者表,其中每个条目对应一个锁地址,并通过线程身份哈希跟踪活跃读者。
  • 将每个读者的线程 ID 与锁地址进行哈希,计算出在可见读者表中的索引,将更新分布到数组中。
  • 允许读者原子地尝试将其计算出的表项安装锁地址,向写者信号其存在。
  • 确保地址空间中所有锁和线程共享同一个可见读者表,实现跨锁协调,且开销极小。
  • 利用哈希机制减少同一锁的读者之间的竞争和缓存行共享,提升 NUMA 局部性。

实验结果

研究问题

  • RQ1是否可以增强紧凑的读写锁,使其在不显著增加内存占用的前提下支持可扩展的并发读取?
  • RQ2与集中式读者状态管理相比,将读者存在感更新分布到共享表中是否能减少缓存一致性流量?
  • RQ3线程身份哈希在多大程度上改善了读者表中的负载分布并减少了竞争?
  • RQ4与传统锁和基于组群的读写锁相比,BRAVO 在高并发、读取主导的工作负载下的表现如何?
  • RQ5BRAVO 是否可以以极小的改动应用于现有锁实现,且不牺牲向后兼容性?

主要发现

  • BRAVO 通过将读者信号分布化,减少了缓存一致性流量,使现有读写锁在高并发读取下实现高效可扩展性。
  • 使用线程身份哈希将读者更新分布到可见读者表中,最小化了竞争并提升了 NUMA 局部性。
  • BRAVO 仅增加两个额外的整数字段,保持了紧凑的锁表示,避免了组群式设计的膨胀。
  • 共享的可见读者表使地址空间中所有锁和线程能够高效协调读者存在感,显著提升了可扩展性。
  • 通过将读者更新扩散到整个表,BRAVO 减少了缓存行失效的频率,在读取密集型工作负载下提升了整体系统吞吐量。
  • 该转换轻量且与现有锁实现兼容,可实现极小工程投入的部署。

更好的研究,从现在开始

从论文设计到论文写作,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。