3 ms·
That only solves work blocked on I/O, and it only solves a subset of that because you can't move all I/O to select/poll/epoll/kqueue. One example is regular fil
by klodolph 6y ago
That only solves work blocked on I/O, and it only solves a subset of that because you can't move all I/O to select/poll/epoll/kqueue. One example is regular files, which cannot be made non-blocking.
There are some async APIs for regular files and we've got io_submit coming in, but it's still not a complete solution and never will be.
On the other hand, spawning threads works everywhere and is cheap enough.
- pansa2 6y ago> One example is regular files, which cannot be made non-blocking. AFAIK this is true on Linux but it’s not true on Windows, which allows “overlapped I/O” on files. Not sure about other operating systems.
- wahern 6y agoWith io_uring Linux now also has async file I/O. Though async file I/O in both Linux and Windows is still implemented using a pool of kernel threads, in contrast to network I/O.
- gpderetta 6y agoI mean go's select or wathever the channel multiplexer is called.
- Animats 6y agoYou may also be blocked for non I/O reasons. This is a typical problem in user interfaces. Code designed to deal with 10 items suddenly has to deal with 10,000, and that takes seconds. During this period, your "async" code is stalled. Typical example - text edit box implemented in Javascript trying to deal with a large block of text.