r/C_Programming • u/Sibexico • Jun 20 '26
epoll vs io_uring in Linux I/O
https://sibexi.co/posts/epoll-vs-io_uring/Short overview of epoll and io_uring and my opinion about what to use in the modern systems. I hope the blog post will be helpful. Always open to feedback, questions and corrections. The post represents my opinion, and yes, I know about potential problems of io_uring, part of them was highlighted in the post. Anyway, I'll be rly interested in discussing the topic.
33
Upvotes
15
u/runningOverA Jun 20 '26
The switch from worker based server, to epoll, showed a huge jump in performance — I can assume.
But,
I was wondering what was the gain in performance jumping from epoll to io_uring?
Last time I read, and that was from early 2020s, servers were struggling to gain more speed jumping to io_uring from epoll. ie, they didn't see any real world overall difference, if any.
Guess things might have changed now.
8
u/not_a_novel_account Jun 21 '26 edited Jun 21 '26
Naive usage of io_uring as a direct replacement for epoll will always bench slower, at least for networking. Obviously it's the only option for async file I/O. The SQE/CQE machinery is a tax on each operation and if you're only doing single operations you pay that tax constantly. This ends up being more expensive than the overhead batching a handful of
read()/write()syscalls each loop saves you.To use io_uring effectively and beat epoll you need to take full advantage of its facilities. That means direct descriptors, collections of at least page-sized registered buffers, multi-shot reads, etc, etc. That will get you at-par. The real performance improvements come from zero-copy, which is still nascent.
And that's a lot of work. It's worth it, if latency is genuinely something you care about, but it effectively requires a structured concurrency framework to use efficiently.
For "I just want to wait on a couple sockets", epoll remains the better option for trivial applications.
7
u/TwystedLyfe Jun 20 '26
For SOCK_STREAM, how does a completion based model look when each data chunk is prefixed with a fixed header. I need to read the header to know how big a buffer I need to alloc before reading the data.
I have many fd's working in a loop on this model. The classic pselect/ppoll/epoll/kqueue pattern works fine and is very portable for this.
1
u/bullno1 Jun 21 '26
Another not often cited advantage is the API: