Get the latest tech news

Lockless MPSC/SPMC/MPMC queues are not queues


Lockless queues let multiple cores communicate with each other without mutexes, typically to move work around for parallel processing. They come in four variants: {single,multi}-producer {single,multi}-consumer. A producer gives data to a consumer, each of which can be limited to a single thread (i.e. a single-{producer,consumer}) or shared across multiple threads. But only the single-producer single-consumer (SPSC) queue is actually a queue!

Lockless queues let multiple cores communicate with each other without mutexes, typically to move work around for parallel processing. For this reason (and let’s be real mostly because unbounded channels are hard), the lockless bags I’ve implemented are unconfigurably bounded. The next article in the series explores the idea of novel instructions that would hardware accelerate lockless bags to significantly outperform all possible software channel implementations.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of SPMC

SPMC

Photo of Lockless MPSC

Lockless MPSC

Photo of MPMC queues

MPMC queues