Building more efficient locks
summary
Shows a practical implementation that reduces a mutex to a single-byte lock using futex/parking-lot ideas and an embedded hashmap of per-address wait queues, so the uncontended path is one compare-and-exchange and contention hits an atomic wait/notify slow path (or a condition-variable fallback). Demonstrates pause/yield usage, compare_exchange weak vs strong choices, acquire/release atomics, and how to build condition variables, events and semaphores. Claims faster than spinlocks for uncontended cases, smaller memory footprint than OS mutexes, and requires heavy unit/soak testing and sanitizers.
AI-written summary · about
chapters (23)
- 0:00Efficient locks intro
- 1:05Ideal lock traits
- 2:53Mutex with spinlock
- 4:41Cache coherence MESI
- 9:16Optimizing spinlocks
- 11:01Out-of-order execution
- 15:56Pause instruction
- 17:22Memory reordering risks
- 20:56Acquire/release ordering
- 23:29OS scheduler yielding
- 25:55Atomic wait/notify
- 29:02Parked bit for contention
- 31:52OS mutex fallback
- 33:58Atomic wait/notify impl
- 36:05Uncontended mutex opt
- 37:07CAS weak vs strong
- 39:55Condition vars with atomic wait
- 42:22Mutex summary parking lots
- 43:25Q&A: C++ std locks
- 45:32Q&A: Testing edge cases
- 47:00Q&A: CAS failure scenarios
- 48:28Q&A: Real-world testing
- 49:57Q&A: Memory ordering
related talks
01h 02mMaking Games Start Fast: A Story About Concurrency
57mOptimising Data Building In Game Development
01h 04mParallel Game Engine Design
01h 01mGame engine using STD C++ 11
52mBuilding a Coroutine based Job System without Standard Library
29mBevy's immutable components: managing side effects in a parallel world
41mBeyond OOP: A Journey From Cache Misses to MASS Hits
41mA Dwarf Fortress Clone In Elixir: A Story Of Doing It Wrong
