List-based implementations of sets are a fundamental building block of many concurrent algorithms. A skiplist based on the lock-free list-based set algorithm of Michael will be included in the JavaTM Concurrency Package of JDK 1.6.0. However, Michael's lock-free algorithm has several drawbacks, most notably that it requires all list traversal operations, including membership tests, to perform cleanup operations of logically removed nodes, and that it uses the equivalent of an atomically markable reference, a pointer that can be atomically “marked,” which is expensive in some languages and unavailable in others.
We present a novel “lazy” list-based implementation of a concurrent set object. It is based on an optimistic locking scheme for inserts and removes, eliminating the need to use the equivalent of an atomically markable reference. It also has a novel wait-free membership test operation (as opposed to Michael's lock-free one) that does not need to perform cleanup operations and is more efficient than that of all previous algorithms.
Empirical testing shows that the new lazy-list algorithm consistently outperforms all known algorithms, including Michael's lock-free algorithm, throughout the concurrency range. At high load, with 90% membership tests, the lazy algorithm is more than twice as fast as Michael's. This is encouraging given that typical search structure usage patterns include around 90% membership tests. By replacing the lock-free membership test of Michael's algorithm with our new wait-free one, we achieve an algorithm that slightly outperforms our new lazy-list (though it may not be as efficient in other contexts as it uses Java's RTTI mechanism to create pointers that can be atomically marked).
[1]
Maurice Herlihy,et al.
Linearizability: a correctness condition for concurrent objects
,
1990,
TOPL.
[2]
Rudolf Bayer,et al.
Concurrency of operations on B-trees
,
1994,
Acta Informatica.
[3]
Maurice Herlihy,et al.
The Repeat Offender Problem: A Mechanism for Supporting Dynamic-Sized, Lock-Free Data Structures
,
2002,
DISC.
[4]
Maurice Herlihy,et al.
Proving correctness of highly-concurrent linearisable objects
,
2006,
PPoPP '06.
[5]
Maged M. Michael.
Safe memory reclamation for dynamic lock-free objects using atomic reads and writes
,
2002,
PODC '02.
[6]
Doug Lea.
Concurrent Programming in Java. Second Edition: Design Principles and Patterns
,
1999
.
[7]
Doug Lea,et al.
Concurrent Programming In Java
,
1996
.
[8]
Maged M. Michael,et al.
High performance dynamic lock-free hash tables and list-based sets
,
2002,
SPAA '02.
[9]
Maurice Herlihy,et al.
Wait-free synchronization
,
1991,
TOPL.
[10]
Timothy L. Harris,et al.
A Pragmatic Implementation of Non-blocking Linked-Lists
,
2001,
DISC.
[11]
Doug Lea,et al.
Concurrent programming in Java - design principles and patterns
,
1996,
Java series.
[12]
John D. Valois.
Lock-free linked lists using compare-and-swap
,
1995,
PODC '95.