A lock-free atomic shared_ptr
summary
Shows that a lock‑free std::atomic<std::shared_ptr> is implementable by using a split refcount (local + global) and either a packed pointer or double‑width CAS; builds prototypes and compares three open implementations (Folly is production‑ready, others are proof‑of‑concept). Benchmarks report lock‑free versions are slower on average but give orders‑of‑magnitude better worst‑case latency, and packed‑pointer variants run 2–3× faster. Notes practical problems: aliasing requires extra allocation or pointer‑delta packing, and portability breaks across compilers/CPUs.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 1:04Atomic shared pointer basics
- 7:03Shared pointer internals
- 9:04Atomic operations and C++20
- 16:04The lock-free implementation challenge
- 21:29Split reference counting algorithm
- 32:21Optimizations and trade-offs
- 35:26Handling aliased shared pointers
- 44:23DWCAS and pointer packing
- 52:55Existing implementations and benchmarks
- 58:27Future work and conclusion
related talks
01h 28mA lock-free std::atomic std::shared_ptr
01h 11mLock-Free Programming (or, Juggling Razor Blades), Part II
52mNonblocking algorithms/ CAS/Atomics
01h 03mSafety: off --- How not to shoot yourself in the foot with C++ atomics
01h 30mLive Lock-Free or Deadlock (Practical Lock-free Programming)
39mLive Lock-Free or Deadlock (Practical Lock-free Programming)
01h 32mLock-free programming with modern C++
01h 14m“C++ atomics, from basic to advanced. What do they really do?”
