The size of a data structure (i.e., the number of elements in it) is a widely used property of a data set. However, for concurrent programs, obtaining a correct size efficiently is non-trivial. In fact, the literature does not offer a mechanism to obtain a correct (linearizable) size of a concurrent data set without resorting to inefficient solutions, such as taking a full snapshot of the data structure to count the elements, or acquiring one global lock in all update and size operations. This paper presents a methodology for adding a concurrent linearizable size operation to sets and dictionaries with a relatively low performance overhead. Theoretically, the proposed size operation is wait-free with asymptotic complexity linear in the number of threads (independently of data-structure size). Practically, we evaluated the performance overhead by adding size to various concurrent data structures in Java$-$a skip list, a hash table and a tree. The proposed linearizable size operation executes faster by orders of magnitude compared to the existing option of taking a snapshot, while incurring a throughput loss of $1\%-20\%$ on the original data structure's operations.
翻译:数据结构的大小(即其中元素的数量)是一组数据集广泛使用的属性。然而,对于同时运行的程序来说,取得正确大小是非三维的。事实上,文献并没有提供一种机制,以便在不采用效率不高的解决办法的情况下,获得一个同时运行的数据集的正确(线性)大小,例如对数据结构进行全面截图以计算元素,或者在所有更新和规模操作中获得一个全球锁定。本文件提出了一个方法,用于在功能管理相对较低的数据集和词典中添加一个同时可线性大小操作。理论上,拟议的尺寸操作在线条数量上(独立于数据结构大小)没有等待,而没有等待不那么复杂的线条数。实际上,我们通过将Java$-$ 跳出列表、 hash表和树中的各种并行数据结构的大小加起来,来评估性能管理。提议的可线性大小操作比现有的快速度选项更快地按数量顺序执行,同时在原始数据结构操作上造成负负值损失1 ⁇ -20 $。