简体   繁体   English

使用 io_uring 进行多路复用

[英]Multiplexing with io_uring

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.我最近使用 epoll 编写了一个简单的 TCP 服务器,但我想探索其他高性能多路复用机制,为此我遇到了 io_uring,并计划使用它制作另一个简单的 TCP 服务器。

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.但是,我在https://kernel.dk/io_uring.pdf 中读到 io_uring 的条目数限制为 4096,这似乎意味着理论上我将无法拥有超过该数量的持久连接。

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?据我了解,通常我会使用epoll_wait()类的东西来等待 epoll 的事件,而是在 io_uring 中提交特定请求,并在请求完成/失败时收到通知,这是否意味着我可以提交最多4096 read() 请求例如?

Have I misunderstood the use case of io_uring or have I misunderstood how to use it?我误解了 io_uring 的用例还是误解了如何使用它?

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.但是,由于 sqe 生存期只是实际提交的生存期,因此应用程序可能会驱动比 SQ 环大小指示的更高的待处理请求计数。

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.这正是您在大量套接字上侦听消息的情况下所做的 - 只是您一次可以发送的提交数量上限为 4096。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM