0

I've recently written a simple TCP server using epoll, but I want to explore other mechanisms for high performance mutliplexing, to that end I came across io_uring, and am planning on making another simple TCP server using it.

However I read that the number of entries for io_uring is limited to 4096 in here https://kernel.dk/io_uring.pdf, which seems to imply that I won't be able to theoretically have more than that number of persistent connections.

To my understanding where normally I'd use something like epoll_wait() to wait on an event for epoll, I instead submit a specific request in io_uring and am notified when the request has completed/failed, so does that mean I can submit up to 4096 read() requests for example?

Have I misunderstood the use case of io_uring or have I misunderstood how to use it?

warmtea
  • 107
  • 9
  • So after a year, did you figure out why io_uring has designed a fixed number of 4096 max entries ? – Bob Feb 03 '22 at 15:23
  • @Bob you can only submit 4096 entries at once, that's just a design decision by the author of io_uring. But there is no limit to how many entries you can submit in total though, so you can only submit 4096 at once, but you can submit up to 4096 multiple times, and therefore submit as many as you want to – warmtea Feb 04 '22 at 17:16
  • If the 4096 entries I submitted were very slow to be consumed, wouldn't the ring be full ? – Bob Feb 16 '22 at 10:40
  • According to [here](https://unixism.net/loti/ref-liburing/submission.html?#c.io_uring_submit) if you do `io_uring_get_sqe()` 4096 times, and then after all of those do a single `io_uring_submit()`, then the ring would be full yes, otherwise it should not – warmtea Feb 17 '22 at 13:20

1 Answers1

3

In the same document I linked, it says:

Normally an application would ask for a ring of a given size, and the assumption may be that this size corresponds directly to how many requests the application can have pending in the kernel. However, since the sqe lifetime is only that of the actual submission of it, it's possible for the application to drive a higher pending request count than the SQ ring size would indicate.

Which is precisely what you'd do for the case of listening for messages on lots of sockets - it's just that the upper limit of how many submissions you can send at once is 4096.

warmtea
  • 107
  • 9
  • In my understanding, you can probably use iouring's poll or epoll interface (or use poll/epoll directly) to poll for the descriptor, once data in/out is ready, you can then submit readv/writev requests to sqe, in this way, the requests on sqe will be processed immediately and they will never be held idle. Thus you can achive much higher concurrency than 4096. – user534498 Dec 09 '20 at 08:07
  • 1
    That's definitely the case, but my confusion at that point was pretty much just that I didn't realise the 4096 is merely an upper limit to how many can be submitted at once, rather than some sort of inflight count – warmtea Dec 10 '20 at 00:42