Concurrent data structures

Hand-drawn hatched terracotta strands weaving over and under one another through two narrow pinch points, over diagonal cream, sand, umber and moss hatching.

A concurrent data structure is a collection, such as a map, a queue or a counter, that several threads of one program read and change at the same time. Its design settles two things: what callers can observe while operations overlap, and how throughput holds up as threads compete for the same data. The main dispute is whether lock-free designs, which never make a thread wait for a lock, beat well-built locks in practice. One study measured gains of 20–40% in applications, while another found the two close until threads outnumber processor cores (Michael & Scott, 1996a; David et al., 2015).

Progress and consistency guarantees

Concurrent designs are classified by what progress they promise when some threads are slow or paused. With a lock, a thread that is paused while holding it stops every thread waiting for it. A lock-free structure guarantees that some operation completes within a finite number of steps while threads keep trying (Michael & Scott, 1996b). A wait-free structure makes the stronger promise that every operation completes in a finite number of its own steps, whatever the speed of other threads (Herlihy, 1991).

A wait-free design can still be fast. In tests on x86 and PowerPC processors, the wait-free queue wCQ often competed with the best concurrent queues. The lock-free LCRQ was faster in some tests (Nikolaev & Ravindran, 2022).

The usual consistency guarantee is linearizability. A history of overlapping calls is linearizable when it matches some one-at-a-time sequence of complete operations that keeps the real-time order of calls that did not overlap (Wing & Gong, 1993). Weaker guarantees exist: the iterators of Java’s concurrent skip-list map are only weakly consistent (Oracle, n.d.g).

Locks or lock-free designs

Studies disagree on how much lock-free designs gain over locks, and the answer depends most on whether threads outnumber cores. On a 1990s multiprocessor, lock-free stacks, queues and counters beat both ordinary locks and locks designed to survive preemption. The margin was 20–40% in real applications and 40–55% in synthetic tests (Michael & Scott, 1996a).

A later benchmark of search structures found lock-based and lock-free versions of each structure often close in performance. Lock-freedom mattered when a program ran more threads than the hardware could run at once, where it scaled better (David et al., 2015). Running more threads than cores is called oversubscription.

Under oversubscription, combining queues degraded sharply in two studies, while lock-free queues held up better. A thread that holds a lock or runs others’ requests can be descheduled, and everyone waits for it. In one study, past 20 threads on one processor, a flat-combining queue (where one thread executes a batch of other threads’ requests) lost 40 times its throughput. A related combining queue, CC-Queue, lost 15 times, leaving the lock-free LCRQ about 20 times faster than CC-Queue (Morrison & Afek, 2013). A second study, running 2 to 128 threads on a four-core processor, found that flat combining degraded while the lock-free Michael–Scott and LCRQ queues kept their performance (Scogland & Feng, 2015).

Locks that put waiting threads to sleep, rather than spinning, can do well under oversubscription too. Meta’s Folly library has a queue that blocks waiting threads through the operating system. Its maintainers report it outperforms Intel’s TBB queue when threads far outnumber cores (Meta, n.d.). In a developer’s Rust benchmark with 16 producers and 16 consumers, a queue guarded by a mutex reached 17.4 million operations per second, against 8.7 million for a ring buffer. That ring itself falls back to sleeping when it cannot proceed, so the test does not pit a lock against a strictly lock-free queue (novoyd, n.d.).

Lock implementations Strong evidence: many studies agree on this

No single lock algorithm is best: the winner changes with the application, the processor and the ratio of threads to cores. A lock can keep its cost flat as contention grows. In the MCS lock, each waiting thread spins on its own local flag. Each acquisition then causes a fixed amount of traffic between processors, however many threads compete (Mellor-Crummey & Scott, 1991).

In an evaluation of 27 mutex algorithms, no lock was best for more than 52% of the applications sensitive to locking, even with each lock tuned for contention. On a MySQL workload with far more threads than cores, most locks delivered performance close to zero. The main conclusions held when scheduling was per memory node (Guiroux et al., 2016).

The processor also changes the ranking. In one comparison, locks that spin for a while and then sleep performed better on AMD than on Intel processors. On AMD, two of them beat a lock that only sleeps (Laforet et al., 2025). Some machines have non-uniform memory access (NUMA): reaching another processor’s memory is slower. On such machines, reader-writer locks aware of that layout improved one benchmark by up to 40% over the best earlier locks (Calciu et al., 2013).

Concurrent maps

Library documentation narrows what each concurrent map is for. Java’s ConcurrentHashMap lets lookups generally proceed without blocking, even while updates run (Oracle, n.d.f). Java’s ConcurrentSkipListMap keeps keys sorted, and its ascending views are faster than its descending ones (Oracle, n.d.g).

Go’s sync.Map is a specialised map for two cases: keys written once and read many times, and threads working on separate sets of keys. Its documentation tells most programs to use a plain map with their own locking instead (Go, n.d.).

Concurrent hash tables

Concurrent hash tables scale well until many threads hit the same few keys. In one study, a table that grows while in use ran about 11 times faster than a single-threaded growing table. A table of fixed size reached about 15 times. In the same study’s tests with frequently accessed keys, a cuckoo hash table was about 6,200 times slower on contended lookups than a specialised fixed-size table (Maier et al., 2019).

The best table for reads is not always the best overall. In one database benchmark held in main memory, the CLHT table beat the IcebergHT table on a workload of lookups only, but used three times the space (Pandey et al., 2023b).

Ordered maps and range queries

Benchmarks of concurrent ordered maps disagree, because their rankings change with the workload. One study showed six workloads that produced all six possible rankings of the three most popular Java concurrent search trees (Galiev et al., 2024). An optimistic balanced tree averaged 32% more throughput than Java’s skip-list map across one benchmark suite. Yet it ran 13% slower with 64 threads, 2,000 possible keys and a mix of 70% lookups, 20% inserts and 10% removals (Bronson et al., 2010). With the same range-query method, a tree beat a skip list under heavy contention, and the skip list won on smaller data under light contention (Chatterjee, 2017).

A range query that must see a consistent snapshot while updates continue changes which map wins. The KiWi map ran 1.25 to 2.5 times faster than three Java ordered maps on lookups, while SnapTree was about 10% faster than KiWi on inserts with 32 threads. In the same study, the long scans of a k-ary tree deteriorated under contention (Basin et al., 2020). In another study, scans of more than 64 keys notably cut the throughput of read-log-update, while four other methods held up as ranges grew (Zhang et al., 2025g).

Designers of new range-query methods report large gains over earlier ones. One technique for linked structures reported gains of 1.2 to 1.8 times for skip lists and 1.3 to 3.7 times for search trees on mixed workloads (Nelson-Slivon et al., 2022). The skip hash is an ordered map. In its designers’ all-lookup benchmark, it ran more than twice as fast as every other index tested, except a plain hash map that cannot answer range queries (Rodriguez et al., 2025).

Queues and channels

Standard-library queues differ in capacity and in what they do when full or empty, so a throughput comparison is meaningful only between queues that behave alike.

What libraries provide

Standard queues differ in what a full queue does to a caller. Java’s ArrayBlockingQueue makes put wait for space, while its one-argument offer returns false at once (Oracle, n.d.a). Python’s Queue blocks on put when full, raises an exception for a non-blocking put, and becomes unbounded when its maximum size is zero or less (Python Software Foundation, 2026). Rust’s sync_channel has a fixed buffer that blocks senders when full; with capacity zero, each send waits for a receiver (The Rust Project, 2026a).

Kotlin’s buffered channel also serves as a rendezvous channel when its capacity is zero (Kotlin/kotlinx.coroutines, n.d.). Its algorithm advances two counters, one for sends and one for receives, with an atomic fetch-and-add instruction, and its authors integrated it into Kotlin’s coroutine library (Koval et al., 2022). The library’s release 1.7.0 advertised a new channel implementation with significant performance improvements (Kotlin/kotlinx.coroutines, 2023).

A ring buffer inside a queue does not mean the queue is bounded. LCRQ closes a ring when it fills and links a new one behind it, so the queue as a whole can grow without limit (Romanov & Koval, 2023).

Measured queue designs Strong evidence: many studies agree on this

Queue rankings depend on how many threads produce and consume, and on how often the queue runs empty. Finer locking helps: a queue with separate locks for its head and tail beat a single-lock queue under contention, and a lock-free queue beat both (Michael & Scott, 1996b).

Specialised queues win in their own topology. With many producers and one consumer, the Jiffy queue ran up to 50% faster than WFqueue and about ten times faster than two general queues, by its authors’ measurements (Adas & Friedman, 2020). For one producer and one consumer, two variants of the FastForward queue had the fewest cache misses in the worst case (Maffione et al., 2018). LPRQ matched LCRQ without needing a compare-and-swap on two words at once (Romanov & Koval, 2023).

A queue that keeps running empty can reverse the rankings. On a GPU, when removals were twice as likely as insertions, LCRQ and WFQ ran at least 2.5 times slower than three other queues. Filling the queues in advance delayed that effect (Kerbl et al., 2018). In another GPU test, three of every four threads only removed items. At 623 threads, LCRQ fell to 0.003 million operations per second, against 91.803 million for a blocking interface (Scogland & Feng, 2015).

GPU queue results have been partly reproduced. An independent framework confirmed the lead of the Broker Queue work distributor on two other NVIDIA graphics cards and found it comparable on an AMD card (Kenzel et al., 2023). A later design was reported to beat that distributor by more than two times while keeping first-in, first-out order (Polak et al., 2025).

Work stealing

Work stealing gives each worker thread its own double-ended queue of tasks: a worker takes from its own queue and steals from others only when it runs out (Chase & Lev, 2005).

Fine-grained tasks favour work stealing by a wide margin. In a synthetic test on 30 cores, the median run took 33.66 ms with Cilk Plus work stealing and 311.92 ms with the central task queue of GNU OpenMP. On the coarsest tasks, GNU OpenMP was slightly faster (Li et al., 2016b). On NUMA machines, a hierarchical scheduler beat both Intel and GNU OpenMP runtimes on five of seven benchmarks (Olivier et al., 2012).

A deque that can grow avoids failures without costing speed. A deque that grows its circular array performed the same as an earlier fixed-array design where both finished, but the fixed array failed in tests where it overflowed (Chase & Lev, 2005).

Java’s ForkJoinPool uses work stealing, both for tasks that spawn subtasks and for many small tasks submitted from outside. The pool compensates when tasks wait on each other. Its documentation does not promise this when a task blocks on I/O or on synchronization the pool does not manage (Oracle, n.d.h).

Read-mostly data and memory reclamation

In a lock-free structure, a removed node cannot be freed at once, because another thread may still be reading it. Reclamation schemes decide when freeing is safe, and they trade throughput against how much retired memory can pile up.

Read-copy-update and read-log-update

Read-copy-update (RCU) separates unlinking an item from freeing it. It waits only for readers that were active during the removal, since later readers cannot reach the removed item (The Linux Kernel, n.d.b). On an eight-core Intel Xeon, user-level RCU reached about 2 million updates per second, against 0.1 million for per-thread locks. Its read throughput fell at high update rates (Desnoyers et al., 2012). Its quiescent-state variant requires each reader thread to report periodically that it holds no references (Userspace RCU, n.d.).

Read-log-update (RLU) lets several writers proceed at once. In a kernel benchmark, it scaled better than an RCU linked list as writers were added, and matched an RCU hash table that locked individual buckets. Replacing reader-writer locks with RLU in the Kyoto Cabinet database tripled performance at 16 hardware threads (Matveev et al., 2015).

Epochs, hazard pointers and reference counting

In epoch-based reclamation, threads announce when they enter and leave an operation, and memory retired in one period is freed once every thread has moved on. Hazard pointers instead have each thread publish the nodes it is about to read. Epochs can be faster, but one stalled thread can block all reclamation. In ordinary epoch-based reclamation, a slow or crashed thread can stop every other thread from reclaiming, so retired memory grows without bound. Still, in a lock-free balanced tree, a distributed epoch scheme beat an efficient hazard-pointer implementation by 75% on average (Brown, 2015).

Reference counting can come close to epochs. A concurrent reference-counting scheme matched epoch-based reclamation on read-mostly workloads, and stayed within 35% in its worst, heavily contended case (Jung et al., 2024).

Reclamation benchmarks have themselves contained bugs. One study found reclamation schemes wrongly integrated in a widely used benchmark suite (Anderson et al., 2021). A later study described those errors as use-after-free bugs and memory leaks (Jung et al., 2024).

Checking correctness Weak evidence: few or small studies support this

Testing tools check concurrent structures against linearizability and find real bugs. The Lincheck framework found previously unknown bugs in popular concurrency libraries for the Java virtual machine (Koval et al., 2023). Its model-checking mode assumes sequential consistency, a memory model in which all threads see writes in one order. Behaviour allowed only by Java’s weaker memory model falls outside that check (JetBrains, 2026). Proving such properties, rather than testing them, is the subject of formal verification.

Further reading

Known gaps

What this article cannot tell you yet.

  1. Transactional memory, in hardware or software, is not covered.
  2. There is no benchmark that compares a mutex which puts waiting threads to sleep with a formally lock-free queue of the same capacity and waiting behaviour while threads outnumber cores.
  3. How CPU queues behave with long idle periods or payloads of varied size is not covered.
  4. How common concurrency bugs are across concurrent data structures is unknown; the testing studies give examples only.
  5. Most queue, map and reclamation measurements come from the authors of one of the designs compared, and only the GPU queue results have been reproduced independently.

References

Solid source
Rated highly trustworthy by the research, and every passage taken from it was found in it.
Weak source
Rated low, or a passage taken from it was not found in it.
Medium trust
Rated medium by the research.
Not checked
Rated high, but its passages could not all be checked against it.
Show all 51 references