轻型锁
Light-weight Locks
摘要:
在本文中,我们提出了一种新的方法来建立同步原语,被称为“lwlocks”(轻量级锁的缩写)。这些原语针对较小的内存占用进行了优化,同时在低争用场景中保持高效的性能。读写lwlock占用4个字节,互斥锁占用4个字节(如果不需要死锁检测,则占用2个字节),条件变量占用4个字节。流行的pthread库的相应原语在x86-64平台上分别占用56字节、40字节和48字节。lwlocks的API与pthread库的API类似,但仅涵盖最常见的用例。Lwlocks允许在争用情况下显式控制排队和调度决策,并支持锁的“异步”或“延迟阻塞”获取。异步锁定有助于解决锁排序的约束,否则会限制并发性。lwlock的小占用空间使得能够构造具有非常细粒度的锁定的数据结构,这反过来对于降低争用和支持对数据结构的高度并发访问至关重要。目前,Data Domain文件系统将lwlock用于其内存中的信息节点缓存,并在通用双向链接并发列表中使用lwlock,后者构成了更复杂结构的构造块。
英文摘要:
In this paper, we propose a new approach to building synchronization primitives, dubbed "lwlocks" (short for light-weight locks). The primitives are optimized for small memory footprint while maintaining efficient performance in low contention scenarios. A read-write lwlock occupies 4 bytes, a mutex occupies 4 bytes (2 if deadlock detection is not required), and a condition variable occupies 4 bytes. The corresponding primitives of the popular pthread library occupy 56 bytes, 40 bytes and 48 bytes respectively on the x86-64 platform. The API for lwlocks is similar to that of the pthread library but covering only the most common use cases. Lwlocks allow explicit control of queuing and scheduling decisions in contention situations and support "asynchronous" or "deferred blocking" acquisition of locks. Asynchronous locking helps in working around the constraints of lock-ordering which otherwise limits concurrency. The small footprint of lwlocks enables the construction of data structures with very fine-grained locking, which in turn is crucial for lowering contention and supporting highly concurrent access to a data structure. Currently, the Data Domain File System uses lwlocks for its in-memory inode cache as well as in a generic doubly-linked concurrent list which forms the building block for more sophisticated structures.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。