Scale Up with Lock Free Algorithms
summary
Implements a lock-free Treiber stack in Kotlin using AtomicReference, measures with JMH benchmarks on a large AWS instance and reports ~20M ops/sec single-thread and roughly 3× better single-thread latency than locks, but worse under pure write contention; after adding realistic work and a read-heavy mix the lock-free version wins and scales up to the machine limit (about 32 hardware threads). Uses AtomicReferenceFieldUpdater/VarHandle boilerplate tradeoffs and an AtomicFu helper to avoid that boilerplate.
AI-written summary · about
chapters (27)
- 0:00Intro
- 1:08What is shareit
- 1:56Why shareit
- 5:13Stack
- 7:41Does it work
- 9:30Does it scale
- 12:07Synchronization
- 13:20Dead Locks
- 14:24Atomic Update
- 15:08Atomic Reference
- 16:33Lock for Algorithms
- 18:53Performance Problem
- 19:31Atomic Reference Updater
- 20:31War Handle
- 21:27Atomic Phone
- 22:43Was it worth it
- 23:03Results
- 25:07Problem
- 25:34Simulation
- 27:44Simulation Whisperer
- 31:02Scaling
- 36:49Books
- 38:07Benchmarking
- 38:38Operations Per Second
- 39:14Virus Techniques
- 39:34Practical Challenges
- 42:42Lock Free vs Synchronized
related talks
47mUsing Java 8 Lambdas and Stampedlock to manage thread safety
50mThe Hidden Art of Thread-Safe Programming: Exploring java.util.con...
46mTowards blocking streams
52mSTM and Structured Concurrency — The Battle with Multithreading Dragons
45mThe Hidden Art of Thread-Safe Programming: Exploring java.util.concurrent
39mProject Loom: Modern Scalable Concurrency for the Java Platform
53mFrom functional programming to assembly - the cost of abstractions....
44mAsync Showdown: Java Virtual Threads vs. Kotlin Coroutines
