3 ms·
Tokio does sync I/O in the background with dedicated I/O threads if memory serves. (it is sync in the sense it does syscalls, which are pushed to a dedicated th
by tuetuopay 3y ago
Tokio does sync I/O in the background with dedicated I/O threads if memory serves. (it is sync in the sense it does syscalls, which are pushed to a dedicated thread).
- dymk 3y agoDepends on the type of I/O (network, file, etc), and the async abstractions that the target operating system supplies.
- littlestymaar 3y agoOnly for file access, which wasn't supported by async on Linux until io-uring.
- nextaccountic 3y agoNo, any spawn_blocking will run on its own dedicated thread
- littlestymaar 3y agoI missread the comment above and read `async` instead of `sync`, my bad. (Your response isn't entirely accurate though: it's using a thread pool whose size is configurable, not one thread per spaw_blocking)
- ReactiveJelly 3y agoEven then I'm pretty sure it's not _a_ dedicated thread, but a thread pool that defaults to a maximum of 512 blocking threads. There's no reason it would bottleneck unrelated writes on unrelated Files through the same thread. I tried to dig into the code here https://news.ycombinator.com/item?id=38180860 https://news.ycombinator.com/item?id=38180860
- 0x457 3y agoTokio has a thread pool for blocking operations. It's not automatic, though, you have to explicitly use it. I don't understand why some people think async is difficult to write. It's difficult if language doesn't have good support for it, but rust does. I remember async ruby was pretty weird to write initially.
- deleted 3y ago[deleted]