Building a Lock-free Multi-producer, Multi-consumer Queue for Tcmalloc
summary
Built a lock‑free MPMC queue to replace the mutexed transfer cache inside tcmalloc, using atomics, widened counters to mitigate ABA, unit tests, fuzzing and sanitizers, microbenchmarks and futex wait/wake for low‑overhead sleeping. Microbenchmarks show up to ~2× throughput at high contention but an early integration shows a 17% web‑search slowdown until futex and sniffing fixes reduce impact; a one‑in‑a‑thousand data race surfaces during fuzzing and is fixed before landing.
AI-written summary · about
chapters (23)
- 0:00Intro
- 1:50CppCon Talk
- 7:12Transfer Cache
- 9:27Standard Queue
- 11:34Claim Insert
- 14:32Commit Line
- 16:05Tcmalloc Optimization
- 17:59Whitebox Testing
- 20:54Testing
- 22:47Debugging
- 26:52ABA Bug
- 28:07Benchmarks
- 30:01Artificial Benchmarks
- 32:55Stat Counters
- 35:34Futex
- 43:12Web Search
- 45:15Concurrent Data Structure
- 46:49Existing Solutions
- 48:31Question
- 52:41Micro benchmarks
- 53:38Mutex under contention
- 57:15Balancing in the background
- 58:25Getting to the online audience
related talks
01h 04mSingle Producer Single Consumer Lock-free FIFO From the Ground Up
01h 02mLock-free programming for real-time systems
01h 01mSmarter Cpp Atomic Smart Pointers - Efficient Concurrent Memory Management
15mThe life cycle of the mm_struct
55mMemory Model: Get your shared data under control
18mQA about PREEMP_RT
53mPREEMPT_RT - How Not to Break It.
30mBPF for Security and LSM updates
