From Problem to Coroutine: Reducing I/O Latency
summary
Uses C++20 coroutines to build a fastq generator that yields each read, moves compute into the coroutine body and resumes on a thread-pool via a promise/awaiter boilerplate; compares that to an old-fashioned producer/consumer thread approach. Result: coroutine version matches the single‑threaded run (≈3.5s for 5M reads) while a threaded consumer cuts it to 1s vs 3.5s. Practical pitfalls include heavy boilerplate, painful debugging and even 5000 spurious coroutines per read when IO is naively offloaded.
AI-written summary · about
chapters (15)
- 0:00Start
- 1:47Experience with Core Routines
- 2:22Introduction to Core Routines
- 13:54Not Using Core Routines
- 16:21Unified Executor Library
- 21:53Offline Offloading the Compute to a Worker
- 24:20Asymmetric Transfer
- 26:35How Does a Function Work
- 28:45Debugging the Core Routines
- 29:45How Does Resume and Compute Pull Work
- 31:17Is Core Routine Handle Passed by Value
- 38:16Created the Promise Type
- 40:50Example Code
- 41:22The Work Goes in the Core Routine Body
- 1:00:22If Core Routines Is Not Faster Why Use It
related talks
01h 02mC++ Coroutines from scratch
41m(Don't) use coroutines for this
54mawait 2.0: Stackless Resumable Functions
01h 04mDeciphering Coroutines - a visual approach
25mAsync Iterators: A New Future for Streams
23mAsync Iterators: a new future for streams
55mBehavioral Modeling in HW/SW Co-design Using C++ Coroutines
22mConcurrency Models Demystified
