Lockless MPSC/SPMC/MPMC queues are not queues
11 hours ago
- #parallel-processing
- #concurrency
- #lockless-queues
- Lockless queues facilitate communication between cores without mutexes, categorized into SPSC, SPMC, MPSC, and MPMC variants.
- SPMC and MPMC queues lack useful ordering guarantees, making them unsuitable as true queues.
- MPSC channels can be viewed as multiplexed producer queues, offering order within individual streams.
- Lockless queues are slow due to linearization requirements and contention over shared memory.
- Lockless bags, an alternative to queues, allow independent operation of producers and consumers, offering wait-free MPMC channels.
- Unbounded channels introduce complexity; bounded channels with backpressure are preferred.
- Lockness Bags are introduced as a new approach but currently underperform queue-based implementations due to cache contention.
- Future hardware acceleration could improve the performance of lockless bags.
- Alternative approaches like stacks, multiple SPSC queues, and tunnel channels have significant drawbacks.