User API & C++ Implementation of a Multi Producer, Multi Consumer, Lock Free, Atomic Queue
Talkat CppCon 2024 · on Tuesday, 2024-09-17· at 09:00· Adams A, 6700 North Gaylord Rockies Boulevard·
summary
Lock-free MPMC queue implemented in C++17 std::atomic, uses a circular array of fixed-size, cacheline-aligned entries, no heap allocation at runtime, and a 16-byte atomic compare‑and‑swap trick (cmpxchg16b / 128‑bit CAS) to atomically flip entry state and data. Benchmarks report up to 703M msgs/s (single‑producer/single‑consumer on a laptop) and sub‑microsecond round‑trip latency; tested on Intel/AMD, supports unique_ptr wrappers for larger payloads, and is available on GitHub.
AI-written summary · about
chapters (12)
- 0:00Lock-free multi-producer queue intro
- 1:29Low-latency queue requirements
- 7:22Fat tails performance impact
- 17:51Hardware atomics for queues
- 22:53Atomics not always lock-free
- 25:22Lock-free queue design
- 31:34Queue API and examples
- 42:28Push and pop operations
- 46:31Testing and validation
- 49:23Performance benchmarks
- 51:34Future work and optimizations
- 54:32Summary and questions
related talks
01h 02mConcurrency Patterns
20mMulti-Queue Fair Queuing
01h 02mBack to Basics: Concurrency
01h 01mReal-time Programming with the C++ Standard Library
39mUsing Race Conditions in Correct Concurrent Software
01h 10mBasic usage of PMRs for better performance
01h 00mMeasuring Qt Performance
01h 01mRefresher on Containers, Algorithms and Performance in C++
