2 ms·
> But coroutines _are_ an option for parallelism, and an especially effective one in the I/O-bound world. Parallelism means that code executes simultaneously (
by spacechild1 3y ago
> But coroutines _are_ an option for parallelism, and an especially effective one in the I/O-bound world.
Parallelism means that code executes simultaneously (on different CPUs). Coroutines (on a single threaded executor) don't do that.
> The parallelism comes from the OS handling I/O scheduling for the coroutines instead of the application code.
Where exactly is the parallelism that is enabled by coroutines? Coroutines are nothing more than resumable functions.
When it comes to I/O performance, threads vs. async is really a false dichotomy. What we should be comparing is
1. threads + blocking I/O
2. non-blocking I/O (select, poll, epoll)
3. asynchronous I/O (io_ring on Linux, IOCP on Windows)
Coroutines may only provide syntactic sugar for 2. and 3.