arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1810.01573cs.OS
收藏

TWA --使用等待阵列增强的票证锁

TWA -- Ticket Locks Augmented with a Waiting Array

Dave Dice, Alex Kogan

摘要:

经典的票证锁由票证和授予字段组成。到达的线程原子地获取并递增票证,然后等待grant变得等于由获取并递增原语返回的值,此时线程持有锁。相应的解锁操作只是增加grant。这种简单的设计在轻度竞争下具有短代码路径和快速切换(所有权转移),但在高度竞争下,当多个线程忙于等待授权字段时(所谓的全局旋转),可能会降低可伸缩性。我们提出了一种票锁的变化,长期等待线程等待在等待数组中的位置,而不是繁忙的等待授予字段。单个等待数组在所有锁之间共享。短期等待是在赠款领域的通常方式完成。由此产生的算法TWA通过限制在任何给定时间在授权字段上旋转的线程数量来改进票证锁,从而减少需要从释放锁的存储无效的远程缓存的数量。反过来,这加速了切换,并且由于在整个切换操作中保持锁定,因此可扩展性提高。在轻度竞争或无竞争下,TWA产生与经典票锁相当的性能,避免了切换路径中MCS锁引起的复杂性和额外访问,但在高竞争下提供高于或超过MCS的性能。

英文摘要:

The classic ticket lock consists of ticket and grant fields. Arriving threads atomically fetch-and-increment ticket and then wait for grant to become equal to the value returned by the fetch-and-increment primitive, at which point the thread holds the lock. The corresponding unlock operation simply increments grant. This simple design has short code paths and fast handover (transfer of ownership) under light contention, but may suffer degraded scalability under high contention when multiple threads busy wait on the grant field -- so-called global spinning. We propose a variation on ticket locks where long-term waiting threads wait on locations in a waiting array instead of busy waiting on the grant field. The single waiting array is shared among all locks. Short-term waiting is accomplished in the usual manner on the grant field. The resulting algorithm, TWA, improves on ticket locks by limiting the number of threads spinning on the grant field at any given time, reducing the number of remote caches requiring invalidation from the store that releases the lock. In turn, this accelerates handover, and since the lock is held throughout the handover operation, scalability improves. Under light or no contention, TWA yields performance comparable to the classic ticket lock, avoiding the complexity and extra accesses incurred by MCS locks in the handover path, but providing performance above or beyond that of MCS at high contention.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑