4 ms·
One of the issues I have with the rust async story is that colored functions require (at least the way they’re handled in rust and similar languages) a separate
by ComputerGuru 6y ago
One of the issues I have with the rust async story is that colored functions require (at least the way they’re handled in rust and similar languages) a separate standard library (Microsoft really outdid themselves providing a synchronous and asynchronous version of the BCL when they shipped async support, but that was also largely made possible by the fact that the underlying OS APIs were all fairly asynchronous at the lowest levels and had that asynchronocity exposed/available all the way through the BCL for C# devs already).
One problem with this is that an api like tokio’s might appear to be asynchronous but in reality portions of it are “just” synchronous API calls marshaled to a thread pool - i.e. none of the real benefits of async for now, but positioned so that the library can be switched over to real async code and automatically take all the consumers with “it in the future.”
I’m glad to hear mention of io_uring because it means that IOCP on Windows might get some love. For those that don’t know, on Linux there is^H^H was really no such thing as properly async file system access (eg libc faked it in a similar fashion for aio) so libraries like mio didn’t bother with true async for non-network parts of the library (and also partially because the biggest motivation for async development was the web world which doesn’t particularly care about asynchronously listing the contents of a directory or writing a “highest” performance backup product) - even though at least some platforms (like Windows) had very compelling async options available across the board.
- anarazel 6y ago> For those that don’t know, on Linux there is^H^H was really no such thing as properly async file system access (eg libc faked it in a similar fashion for aio) That's not quite right - there didn't use to be AIO for buffered filesystem IO and for most operations beyond read/write. But unbuffered reads/writes have been doable asynchronously for quite a long time, via io_submit/libaio. Without falling back to threads. The restrictions around that can be onerous (e.g. one needs to be careful to not extend file sizes, or risk falling back to synchronous operation).
- habitue 6y ago> there didn't use to be AIO for buffered filesystem IO Did they change libaio to work without O_DIRECT at some point? Or are you talking about io_uring for async file io?
- anarazel 6y ago> Did they change libaio to work without O_DIRECT at some point? No, and I don't really forsee that happening at this point. > Or are you talking about io_uring for async file io? Yep. io_uring can do async buffered file IO. Initially, for buffered file IO, everything not in the page cache (e.g. a cache miss read, or a write without a page cache page already existing) was done via kernel threads inside the kernel, but that's being incrementally improved. Now most buffered reads don't need a kernel thread anymore (instead they are submitted during the io_uring_enter, and completed in task context, avoiding a lot of the overhead of "synchronous" execution in a kernel thread).
- deleted 6y ago[deleted]
- rapsey 6y ago> But unbuffered reads/writes have been doable asynchronously for quite a long time That is not quite right because it is dependent on the filesystem. This is why scylla database requires XFS, because they rely on actual async file io using io_submit.
- octoberfranklin 6y ago> portions of it are “just” synchronous API calls marshaled to a thread pool That only happens when OS support is missing. As in, the OS does not support doing something asynchronously. Once io_uring is implemented, there will be no more of these "portions" (at least not on Linux).