-
|
I really like the UDP multishot recv/recvmsg functionally in io_uring. But I really dislike the async nature of io_uring's send/sendmsg. I find I have to cache / pool things like addresses and msghdrs on a send() that will likely not last more than one cycle through the event-loop. Have a bunch of logic around when I can re-use memory... etc. I think I'd prefer to take the syscall overhead and just call normal synchronous send/sendmsg on the socket and be done w/ memory lifetime constraints when the function returns. But I thought it would be best to ask first. Are there any issues with io_uring intermixing different APIs like this? I'm registering my UDP socket fd's, so I'd have to use the "real" fd's on the syscall version. Not sure if that matters here. Also, am I missing something obvious about io_uring, is there a synchronous udp send/sendmsg? Or other common pattern I'm missing? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
|
send/sendmsg through io_uring is generally always sync, except if there's no space in the buffer. I can see how it's very annoying to need to have to retain the data, or iovec/msghdr, on the off chance that the socket is out of space. You can certainly mix and match, but I'm almost pondering if it'd be worthwhile to have some way of "failing" the send/sendmsg if there's no space in the socket. Then at that point you'd want to ensure structs are persistent, but not before then. It would require you to iterate the CQ ring after submission to find those, while you're still in the same context though. Or maybe there are better ideas here? |
Beta Was this translation helpful? Give feedback.
-
|
That's what In short, it might be worthwhile checking the current semantics, and fixing it in place if it does the right thing or correcting it (potentially with some flag) if it doesn't. |
Beta Was this translation helpful? Give feedback.
-
|
Yep, Semantics did take a while to solidify, but they haven't been changed in years at this point. |
Beta Was this translation helpful? Give feedback.
It's sync in the sense of "guarantees that a completion has been posted by the time io_uring_submit() (or any other submit variant) returns". The result delivery is just using the CQ ring, like any completion does, but after submit you'll know that the request has completed - either successfully, as expected, or with
-EAGAINif it could not complete synchronously. And yes that would mean you need some kind of iteration of the CQ ring to find these completion post submit, which isn't necessarily trivial or pretty, depending on what your flow normally looks like.