I/O-bound and CPU-bound work¶
Category: Foundations · Status: stub · Lessons: chapter 07, Parallelism
One line: Work that spends its time waiting for disks and networks gains from concurrency even on one core; work that spends its time computing gains only from parallelism.
Also called: I/O-bound, CPU-bound.
How it connects¶
In each language¶
| Rust | tokio::task::spawn_blocking ↗ moves blocking work off the async worker threads |
| Java | Virtual threads ↗ suit tasks that spend most of their time blocked on I/O, not long CPU-intensive work |
| Python | The threading ↗ docs advise multiprocessing or ProcessPoolExecutor for CPU-bound work, and threads for I/O-bound tasks, because of the GIL |
| C# | Asynchronous programming scenarios ↗ separates I/O-bound work (await the I/O call) from CPU-bound work (await Task.Run) |
| Kotlin | Dispatchers.IO ↗ is for offloading blocking I/O; Dispatchers.Default ↗ uses at most one thread per CPU core (at least two) |
| Erlang and Elixir | A native function that cannot finish within a millisecond is marked dirty and runs on dirty CPU or dirty I/O schedulers ↗, apart from the ordinary ones |
Where to read more¶
- In the books: Asynchronous Programming in Rust, Carl Fredrik Samson — ch. 6, 'Futures in Rust' → 'I/O vs CPU-intensive tasks'
- In the books: Python Concurrency with asyncio, Matthew Fowler — ch. 1, 'Getting to know asyncio' → 'What is I/O-bound and what is CPU-bound?'
- In the books: Grokking Concurrency, Kirill Bobrov — ch. 6, 'Multitasking' → 'CPU-bound and I/O-bound applications'
- In the books: Python in Practice, Mark Summerfield — ch. 4, 'High-Level Concurrency in Python' → 'CPU-Bound Concurrency'
- Notes: CPU-Bound Tasks ↗
- Notes: I/O-bound tasks ↗
- Notes: I/O bottlenecks - general ↗
- Reference: Wikipedia: CPU-bound ↗
- Reference: Wikipedia: I/O bound ↗