axboe / liburing

Library providing helpers for the Linux kernel io_uring support
MIT License
2.77k stars 398 forks source link

io_uring_register_buffers and io_uring_register_buf_ring #1025

Closed lorislibralato closed 7 months ago

lorislibralato commented 8 months ago

Does registering the buffers used in the buf_ring give performance improvements with multishot operations?

isilence commented 8 months ago

If we compare with the legacy provided buffers, i.e. IORING_OP_PROVIDE_BUFFERS, then yes, buf_ring is more performant, not needing to queue extra requests is a huge win.

But note that to use multishot receives in the first place you need one of those -- multishots potentially run indefinitely and you need a way to feed it buffers.

lorislibralato commented 8 months ago

I didn't explained well, If i use io_uring_register_buffer on a buffer added to a buf_ring does It optimize the buffer operations?

isilence commented 8 months ago

I didn't explained well, If i use io_uring_register_buffer on a buffer added to a buf_ring does It optimize the buffer operations?

No, it does not. The kernel doesn't keep track of that association.

If one day there would be providing registered buffers of some sort it should be explicitly reflected in the user API. And nobody cared to implement it because it wouldn't help anyway for the same reason why registered buffers are useless for recv / recvmsg -- there is a memcpy inside the net stack.

A side note, there is a zerocopy recv in development, it requires registered buffers, and long merged send zc also optionally benefits from registered buffers, but for both it's quite explicit.

lorislibralato commented 8 months ago

Ok thanks!