[HN Gopher] Io_uring and Networking in 2023 [pdf]
___________________________________________________________________
Io_uring and Networking in 2023 [pdf]
Author : ingve
Score : 157 points
Date : 2023-02-16 00:08 UTC (1 days ago)
(HTM) web link (kernel.dk)
(TXT) w3m dump (kernel.dk)
| puzpuzpuz-hn wrote:
| 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 wrote:
| 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".
| bullen wrote:
| "Fortunately, future work may make synchronization nonpinning.
| And, refactoring internals of the java.io package and
| implementing OS-level APIs such as io_uring on Linux may reduce
| the number of capturing operations."
|
| https://blogs.oracle.com/javamagazine/post/java-loom-virtual...
| twic wrote:
| 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]?
| espoal wrote:
| i think it should be br[i]
| cgh wrote:
| I think so, yes. struct io_uring_buf_ring is a union that
| includes a bufs member: struct io_uring_buf
| bufs[0];
| axboe wrote:
| 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.
| znpy wrote:
| 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 ?
| signa11 wrote:
| 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 wrote:
| 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.
| unmole wrote:
| Beej's Guide to Network Programming:
| https://beej.us/guide/bgnet/
| mariusor wrote:
| I just went through this recently, and it vastly predates
| io_uring functionality, I don't remember even mentioning it.
|
| It's a good place to learn socket programming using the POSIX
| sockets API, but that's it.
| unmole wrote:
| The GP asked for resources to understand low level network
| programming.
| mariusor wrote:
| ...relevant to io_uring. I was just clarifying that
| Beej's guide is not really that.
| weird_user wrote:
| 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/
| znpy wrote:
| one thing is not clear from the website: the pages in the
| content section (say https://build-your-
| own.org/redis/02_intro_sockets ) are a shortened version of
| the pages in the epub/pdf/paperback version?
| weird_user wrote:
| The web pages are the full version. It's a condensed book.
| cormacrelf wrote:
| If you use io_uring to implement the Promise API, do you call it
| iou_ring?
| kzrdude wrote:
| Why is it called "uring" anyway, what's the u for?
| localplume wrote:
| unlocked ring? the ring buffers are lock free. I'm not sure
| it stands for userspace since the ring buffers are shared
| between kernel and userspace, thats the core of io_uring, so
| that seems kind of misleading.
| riceart wrote:
| Ring buffers for the most part are typically lock free, so
| that's a bit redundant. The special part is that the ring
| is directly accessible from userspace at all, as previously
| any ring buffer is internal.
| Conscat wrote:
| I have struggled searching for any evidence, but most people
| seem to think it's "userspace".
| wyldfire wrote:
| The letter u in contexts like these is usually used to
| represent the greek letter mu -- m -- and like the SI units
| prefix indicates "micro". It might not be the case for
| io_uring, but that's what I'd assumed.
| taskforcegemini wrote:
| that's what I thought as well. and something in relation to
| "micro kernel"
| WJW wrote:
| The "u" in "uring" has nothing to do with its size but
| rather with it being a "userspace ring". The ring buffers
| used by this particular API reside in userspace rather than
| in kernel memory.
| loeg wrote:
| > The ring buffers used by this particular API reside in
| userspace rather than in kernel memory.
|
| More specifically, the physical pages backing these ring
| buffers are pinned and mapped into both address spaces.
| (The kernel needs to be able to read submissions (sqes)
| off of it and write completions (cqes) into it, and could
| not do that if it were only mapped in userspace, or could
| be paged out.)
| axboe wrote:
| This is correct, the "u" is for userspace/usermapped. The
| memory is actually allocate by the kernel, but it's
| mapped into the applications address space.
| erincandescent wrote:
| Userspace
| laerus wrote:
| in the Future this will be funny
| svieira wrote:
| The only Task remaining is to wait until that Future is
| joined.
| espoal wrote:
| added to awesome-iouring https://github.com/espoal/awesome-
| iouring
| neverartful wrote:
| How does io_uring relate (if at all) to DPDK and SPDK?
| ilc wrote:
| 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.
| jswrenn wrote:
| dupe (2 days ago): https://news.ycombinator.com/item?id=34798281
| twic wrote:
| And for some reason this time it's a PDF.
___________________________________________________________________
(page generated 2023-02-17 23:01 UTC)