This repository contains benchmarks for different implementations of linked list based concurrent set. The algorithms are taken from The Art of Multiprocessor Programming, 2nd edition, 2021, by Herlihy, Shavit, Luchangco and Spear.
- AMD Ryzen 7 2700X Eight-Core Processor, 16 cores
- 32GiB DIMM DDR4 2933 MHz
- Fedora 32 (Linux kernel 5.7.8)
CoarseGrainedSyncSet
FineGrainedSyncSet
OptimisticSyncSet
LazySyncSet
NonBlockingSyncSet
Two arrays are provided for each benchmark case:
- Ascending array
ascendingArray := [1, ..., 1024]
(1024 items total) - Shuffled array
rand.Shuffle(ascendingArray)
(1024 items total)
In each benchmark, every thread is trying to insert/seek/remove the full input array.
- Half of the threads are inserting items from the input array to the set, while the other half is seeking for the items.
- Half of the threads are inserting items from the input array to the set, while the other half is removing the items.
- In the benchmarks implying concurrent writes and reads
LazySyncSet
showed better results. - In the benchmarks implying concurrent writes and deletions everything it's important to compare on the number of CPU cores and concurrent threads: if the number of threads exceeds the number of CPU cores,
NonBlockingSyncSet
is better, otherwise useLazySyncSet
. - When it comes to concurrent reads (with no mutations at all),
CoarseGrainedSyncSet
wins because it acts as wait-free data structure (due tosync.RWMutex
), and it's faster than optimistic implementations because it doesn't need to validate the discovered node.