Work Contracts - Rethinking Task Based Concurrency & Parallelism for Low Latency C++
summary
Work Contracts replaces task queues with a compact, lock‑free (often wait‑free) signal tree that lets threads traverse different branches to claim work. Benchmarks run with up to 16 threads and 16k queued items show scaling at high contention (17 ns tasks) with roughly 40x faster throughput versus moodycamel and ~100x versus average MPMC queues, using about half the memory. Contracts hold logic (repeatable calls), offer single-threaded execution per contract, support async deterministic destruction, and pair naturally with SPSC data queues; the implementation is built and benchmarked, and the numbers are concrete.
AI-written summary · about
chapters (39)
- 0:00Introduction
- 0:26Problems with task queues
- 1:29Decoupling logic and data
- 4:54Introduction to work contracts
- 6:00Signal tree structure
- 7:40Benchmark setup
- 9:07Performance results
- 13:06Low contention benchmark
- 15:23Medium contention benchmark
- 16:25High contention benchmark
- 17:24Empty task benchmark
- 18:15Signal tree advantages
- 20:43Perfect binary tree
- 21:49Setting a signal
- 22:56Selecting a signal
- 24:50Task selection bias
- 26:40Task selection fairness
- 27:48Prioritization mechanism
- 28:34Prioritization summary
- 29:32Work contract overview
- 30:17Hello world example
- 32:34State and destructors
- 33:19Asynchronous destruction
- 35:02Error handling
- 35:38Repeatable invocation
- 36:08Data handling
- 38:38Single threaded guarantee
- 39:43Token usage
- 39:55Looping and destruction
- 42:02Threading example
- 42:21Parallel execution
- 43:16Output mangling prevention
- 43:37SPSC queue integration
- 44:24SPSC queue example
- 46:13Concurrency summary
- 46:24Conclusion
- 46:36Talk recap
- 49:32Acknowledgments
- 50:21Q&A
related talks
01h 04mThe C++20 Synchronization Library
01h 04m[old version]The C++20 Synchrononization Library
05mFast Parallel Programming using Modern C++
52mBest Practices for Concurrency
57m[filtered] Asynchronous C++ Programming
01h 02mTaro: Task Graph-Based Asynchronous Programming Using C++ Coroutine
01h 06mAsynchronous Computation in C++
48mConsiderations for choosing the parallel computing strategy
