top | item 36033768

(no title)

martinjacobd | 2 years ago

I recently tinkered around with io_uring for a presentation. Here is a toy echo server I made with it: https://gist.github.com/martinjacobd/be50a93744b94749339afe8... (non io_uring example for comparison: https://gist.github.com/martinjacobd/feea261d2fafe5e7332e37d...)

A big todo I have for this is to modify it to accept multishot_accept but I haven't been able to get a recent enough kernel configured properly to do it. (Only >6.0 kernels support multishot accept).

(edit) you need to s/multishot_accept/recv_multishot/g above :)

discuss

order

thinkharderdev|2 years ago

I did an echo server with multi-shot here (using the io_uring rust bindings) https://github.com/thinkharderdev/io-uring/blob/ring-mapped-.... My biggest issue with io_uring is figuring out what is available in which kernel version :)

martinjacobd|2 years ago

I meant recv_multishot not multishot_accept. The one I linked does use multishot_accept. Just a think-o. Looks like your version uses both though, so that's cool.

samsquire|2 years ago

I might have to use your code again, I used your Just in time compilation code to execute generated machine code.

Thank you so much Martin Jacob!

martinjacobd|2 years ago

Absolutely my pleasure. I tracked down the problem you commented about: I used a later version of liburing than ships with Ubuntu, so if you want to compile this as-is, you'll have to compile and install liburing from source probably. Glad you enjoyed it!

znpy|2 years ago

Could you also do an udp based server? It’d be interesting

martinjacobd|2 years ago

I don't see why not. You'd open the socket on line 124 as a SOCK_DGRAM, 0 rather than what it is now for TCP. For an echo server, for instance, you wouldn't listen on the socket or accept requests; instead, you'd use io_uring_prep_recvmsg and use the prepended msghdr to send the identical packet back out with io_uring_prep_sendmsg.

At least, that's my untested understanding.