7 ms·
One interesting thing is that io_uring can operate in different modes. One of the modes enables kernel-side polling, so that when you put data into the buffer,
by iamwil 3y ago
One interesting thing is that io_uring can operate in different modes. One of the modes enables kernel-side polling, so that when you put data into the buffer, the kernel will pull the data out itself to do IO. That means from the application side, you can perform IO without any system calls.
Our general take was also that it has a lot of potential, but is relatively low level that most mainstream programmers aren't going to pay attention to it. Hence, it'll be a while before it permeates through various ecosystems.
For those of you that like to listen on the way to work, we cover io_uring on our podcast, The Technium.
https://www.youtube.com/watch?v=Ebpnd7rPpdI https://www.youtube.com/watch?v=Ebpnd7rPpdI
https://open.spotify.com/episode/3MG2FmpE3NP7AK7zqQFArE?si=sKNKcrIZRayMeQGTbwkMlw&nd=1 https://open.spotify.com/episode/3MG2FmpE3NP7AK7zqQFArE?si=s...
- eru 3y ago> Our general take was also that it has a lot of potential, but is relatively low level that most mainstream programmers aren't going to pay attention to it. Hence, it'll be a while before it permeates through various ecosystems. Isn't that what libraries are for?
- ori_b 3y agoAs long as you are willing to accept the latency and/or busy looping that the kernel needs in order to poll.
- blibble 3y ago> Hence, it'll be a while before it permeates through various ecosystems. this may take a while as it's a completely different IO model it took us 30 odd years to get from select/epoll to async/coroutines being popular
- mrcode007 3y agoWindows has been using this mechanism for well over a decade now. It’s called IOCP (IO completion ports)
- blibble 3y agoand Linux has had POSIX async IO since 2003 (which no-one uses either because the API doesn't compose well onto existing application structures)
- mananaysiempre 3y agoIf you had mentioned Solaris, I’d have agreed. But POSIX async I/O (the aio_* functions) in Linux is basically worthless performance-wise AFAIU, because Glibc implements it in userspace by spawning threads to do standard sync I/O. Now Linux also has non-POSIX async I/O (the io_* functions), but it’s very situational because it works only if you bypass the cache (O_DIRECT) and can still randomly block on metadata operations (so can Win32, to be fair). There’s select/poll/epoll with O_NONBLOCK of course, which is what people normally use, but those do not really work with files on disk (neither do their WinSock equivalents). Hell, signal-driven IO (O_ASYNC) exists, I’ve used it to make a single-threaded emulator (CPU-bound unlike a network server) interact with the terminal. But asynchronous I/O of normal, cached files is only possible on Linux through the use of io_uring, as far as I’ve been able to figure out. That said, I’ve read people here saying[1] that overlapped I/O on Windows also works by scheduling operations on a thread pool, even referencing KB articles[2]. This does not mesh with everything I’ve read about I/O in the NT kernel, which is supposed to be natively async to the point where the I/O request datastructure (the IRP) has what’s essentially an emulated call stack inside of it, in order to allow the I/O subsystem to juggle continuations. What am I missing? Does the Win32 subsystem need to dumb things down that much even inside its own implementation? (Windows 8 also introduced a ringbuffer-based, no-syscalls thing called Registered I/O that looks very much like io_uring.) [1] https://news.ycombinator.com/item?id=11867351 https://news.ycombinator.com/item?id=11867351 [2] https://support.microsoft.com/kb/156932 https://support.microsoft.com/kb/156932
- GoblinSlayer 3y agoWhy you think you can't use epoll with disk files on linux?
- 3y ago
- fanf2 3y agoI am looking forward to io_uring support in libuv
- CoolCold 3y agoisn't it a thing already https://www.phoronix.com/news/libuv-io-uring https://www.phoronix.com/news/libuv-io-uring ?
- throwaway894345 3y agoDoes this imply that the caller has to poll the result buffer to know when the kernel has processed the initial data?
- sophacles 3y agoSort of. In the strictest sense, yes - the cq is a ring buffer (implemented with fancy atomic stuff), so you have to check if there is a completion on the queue before you read the entry. However, this doesn't need a syscall to do polling, if more completions come in while you're processing, they will be available to you. There's also a syscall (io_uring_enter) that will do a context switch and wake you up when completions are available (it's a complicated syscall, that has a lot of knobs and switches and levers - just be ready for a LOT of information if you go read the man page).
- BeeOnRope 3y agoCan you use the kernel polling mode w/o running as root?
- magicalhippo 3y ago> One interesting thing is that io_uring can operate in different modes. One of the modes enables kernel-side polling [...] On a related note, I recently saw this presentation[1] where they show some benchmarks of the various modes. One gotcha of sorts, though obvious when you think about it, is that the kernel-side polling mode requires a free CPU core for the polling thread. Meaning you'll get very poor performance if you're not leaving enough CPU for the kernel to do its polling. https://www.youtube.com/watch?v=5jKKVdJJqKY https://www.youtube.com/watch?v=5jKKVdJJqKY