A Lazy Concurrent List-Based Set Algorithm
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).
Unable to display preview. Download preview PDF.
- 2.Eckel, B.: Thinking in Java, 2nd edn. Pearson Education (2000)Google Scholar
- 5.Herlihy, M., Luchangco, V., Moir, M.: The repeat offender problem: A mechanism for supporting lock-free dynamic-sized data structures. In: Proceedings of the 16th International Symposium on Distributed Computing, vol. 2508, pp. 339–353. Springer, Heidelberg (2002)Google Scholar
- 7.Lea, D.: Personal communicationGoogle Scholar
- 8.Lea, D.: Concurrent Programming in Java(TM): Design Principles and Patterns, 2nd edn. Addison-Wesley, Reading (1999)Google Scholar
- 9.Maier, C.: Hello Laziness: Why Hard Work Doesn’t Pay. Orion, London (2005)Google Scholar
- 10.Michael, M.: High performance dynamic lock-free hash tables and list-based sets. In: Proceedings of the fourteenth annual ACM symposium on Parallel algorithms and architectures, pp. 73–82. ACM Press, New York (2002)Google Scholar
- 11.Michael, M.: Safe memory reclamation for dynamic lock-free objects using atomic reads and writes. In: The 21st Annual ACM Symposium on Principles of Distributed Computing, pp. 21–30. ACM Press, New York (2002)Google Scholar
- 12.Moir, M., Shavit, N.: Chapter 47 – Concurrent Data Structures – Handbook of Data Structures and Applications, 1st edn. Chapman and Hall/CRC (2004)Google Scholar
- 13.Vafeiadis, V., Herlihy, M., Hoare, T., Shapiro, M.: Proving correctness of highly-concurrent linearisable objects. Technical report, Microsoft Research, Cambridge, UK (2005)Google Scholar
- 14.Valois, J.: Lock-free linked lists using compare-and-swap. In: ACM Symposium on Principles of Distributed Computing, pp. 214–222 (1995)Google Scholar