Engineering MultiQueues: Fast Relaxed Concurrent Priority Queues

Andreas Haas, Thomas A. Henzinger, Andreas HolzerDROPS 2016

TL;DR

This paper introduces "MultiQueues," a novel, simple, and highly scalable relaxed concurrent priority queue designed for parallel systems. By distributing operations across multiple sequential queues and employing a clever "wait-free locking" mechanism, MultiQueues achieve significantly higher throughput than existing solutions while maintaining excellent quality in terms of element retrieval.

What Problem Does This Paper Address?

In modern parallel computing, many applications like scheduling, simulation, and graph algorithms rely on priority queues to manage elements. However, traditional priority queues become a major bottleneck when multiple threads try to access them concurrently. This contention drastically reduces throughput. While "relaxed" priority queues offer a solution by allowing slightly non-minimal elements to be returned, achieving both high throughput and good quality (i.e., elements are close to the true minimum) in a scalable manner remains a challenge. Existing approaches often struggle with either performance or quality, especially as the number of threads increases.

Methods

The core idea behind MultiQueues is to manage a collection of cp sequential priority queues, where p is the number of parallel threads and c is a tuning parameter. This abundance of queues helps to minimize contention.

  • Insertion: Elements are inserted into a randomly chosen sequential queue. This strategy aims to distribute elements evenly across the queues, ensuring each queue holds a representative sample of the global elements.
  • Deletion (deleteMin): To retrieve the minimum element, MultiQueues don't just pick one random queue. Instead, they randomly select two queues and return the minimum from the one with the smaller minimum. This "two-choice" approach helps stabilize the distribution of elements and improves the quality of the returned element.
  • Wait-Free Locking: A key innovation is the use of "wait-free locking" for accessing individual sequential queues. This technique allows threads to attempt to lock a queue and proceed if successful, without getting stuck waiting indefinitely for a locked queue. This is achieved by using atomic operations and ensuring that even if a queue is temporarily locked, other operations can still make progress. This allows the use of standard sequential data structures (like binary heaps) within each queue without complex lock-free implementations.

Datasets

Not discussed in the paper. The experiments evaluate the performance and quality of the MultiQueue data structure itself, rather than on specific datasets.

Key Insights and Ideas

  • Simplicity as a Strength: The paper demonstrates that a surprisingly simple approach (multiple sequential queues) can outperform more complex, specialized concurrent data structures.
  • The Power of "Two-Choice": Randomly selecting two queues for deletion, rather than one, significantly improves the quality of the returned elements by stabilizing distributions and reducing rank error.
  • Wait-Free Locking for Relaxation: The "wait-free locking" mechanism is a crucial enabler, allowing standard sequential data structures to be used concurrently without the overhead of complex lock-free implementations, while still guaranteeing progress.
  • Scalability Through Distribution: By distributing operations across many queues, MultiQueues effectively mitigate contention, leading to excellent scalability with an increasing number of threads.
  • Performance-Quality Tradeoff: MultiQueues offer a compelling balance between high throughput and good quality, often outperforming existing solutions in at least one of these aspects.

Key Results

  • Throughput: MultiQueues demonstrate excellent scalability on single-socket systems, achieving up to 1.7 times higher throughput than SprayList (a leading concurrent priority queue) for c=2 and twice as fast for c=4. Performance scales well up to 14 cores. While there's a performance dip when moving to multiple sockets, MultiQueues still generally outperform SprayList. On a 4-socket machine with 56 threads, MultiQueues are about 1.9x faster than SprayLists for c=2 and 2.5x faster for c=4.
  • Quality (Rank Error): For 56 threads and 10 million operations, 75% of deleted elements in MultiQueues have ranks <= 111 (for c=2) and <= 223 (for c=4). These are significantly smaller than SprayList's ranks (1740 for c=2 and 1522 for c=4), indicating much better quality. The measured rank error distributions closely follow the theoretical analysis.
  • Implementation: The implementation uses 8-ary heaps from the Boost library, which are cache-efficient.

Limitations and Future Work

  • Theoretical Analysis: The paper acknowledges that a closed-form analysis of the quality (rank error) is difficult, though they provide reasonable approximations under simplifying assumptions.
  • Multi-Socket Scalability: While MultiQueues scale well on a single socket, performance degrades on multi-socket systems due to increased memory access latency and cache invalidation overheads. Future work could explore data structures with better cache behavior or amortized update costs.
  • Adaptive Relaxation: The current approach requires specifying the degree of relaxation (c) upfront. Future research could explore adaptive data structures that dynamically adjust relaxation levels to maintain low contention and good quality.
  • Provable Guarantees: The authors express a desire for higher quality, particularly for the tails of the rank distribution, along with provable performance guarantees. They believe this is an open theoretical problem.
  • Empty Queue Detection: Reliably detecting a globally empty queue is noted as a challenge, though it's often an application-level concern.

Summary updated

BibTeX
@inproceedings{haas2016engineering,
  author = {Andreas Haas and Thomas A. Henzinger and Andreas Holzer},
  title = {{Engineering MultiQueues: Fast Relaxed Concurrent Priority Queues}},
  booktitle = {DROPS},
  year = {2016},
  doi = {10.4230/lipics.concur.2016.6},
}
Figure