top | item 34812949

Io_uring and Networking in 2023 [pdf]

169 points| ingve | 3 years ago |kernel.dk | reply

37 comments

order
[+] cormacrelf|3 years ago|reply
If you use io_uring to implement the Promise API, do you call it iou_ring?
[+] laerus|3 years ago|reply
in the Future this will be funny
[+] kzrdude|3 years ago|reply
Why is it called "uring" anyway, what's the u for?
[+] puzpuzpuz-hn|3 years ago|reply
Recently we've started using io_uring for disk access in QuestDB. So far, it's being used in CSV import, but we'd like to expand it to network and other disk access use cases. Apart from the performance boost, the beauty of io_uring is that it allows one to build an event loop on a single I/O multiplexing mechanism. No need to build an ugly combination of epoll and AIO or anything like that - it supports networking, disk access, user events (eventfd), and timers (and not only).
[+] axboe|3 years ago|reply
Thank you for highlighting that, part of the design criteria for io_uring was indeed to be able to do everything. It's even mentioned in the second sentence of the linked write-up, no more "everything is a file... until you need to do IO to it".
[+] twic|3 years ago|reply
In this code:

  for (i = 0; i < BUFS_IN_GROUP; i++) {
    /* add each buffer, we'll use i buffer ID */
    io_uring_buf_ring_add(br, bufs[i], BUF_SIZE, i,
            io_uring_buf_ring_mask(BUFS_IN_GROUP), i);
   }
Where did bufs come from? Should that be br.bufs[i]?
[+] axboe|3 years ago|reply
The buffers are supplied elsewhere outside that example, just consider it an array of pointers to buffers of size BUF_SIZE. br->bufs[] is the shared space, it holds information on the address/size/id of a given buffer.
[+] cgh|3 years ago|reply
I think so, yes. struct io_uring_buf_ring is a union that includes a bufs member:

    struct io_uring_buf    bufs[0];
[+] espoal|3 years ago|reply
i think it should be br[i]
[+] znpy|3 years ago|reply
could anyone suggest where to learn enough network programming in C/Linux to be able to have the necessary background to start using io_uring?

After working on one of our internal pieces of software, I have a strong hunch that io_uring could boost its throughput, and I'd like to have a PoC, but low-level network programming is definitely outside my areas of expertise.

Any suggestions ?

[+] weird_user|3 years ago|reply
I think you need to learn basics like the event loop first before jumping into io_uring.

You might be interested in my book[1] which teaches network programming.

[1] https://build-your-own.org/redis/

[+] signa11|3 years ago|reply
imho, the best resource for this is unix-network-programming from stevens. i would recommend that you start with his tcp-ip-illustrated-vol-1 first, and then progress from there.

other resources are more of a 'tactical' nature, while what you need is something more strategic.

[+] hedora|3 years ago|reply
Find a tutorial that explains how to implement an async runtime on top of epoll using C++20 coroutines. In that context, it is probably easier to use io_uring correctly than epoll.
[+] neverartful|3 years ago|reply
How does io_uring relate (if at all) to DPDK and SPDK?
[+] ilc|3 years ago|reply
It doesn't really.

DPDK/SPDK are ways to directly to use the device involved.

io_uring is a way to manage event flow between the kernel and userspace.