Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quinn_proto example with io_uring #1452

Open
espoal opened this issue Nov 23, 2022 · 5 comments
Open

quinn_proto example with io_uring #1452

espoal opened this issue Nov 23, 2022 · 5 comments
Labels

Comments

@espoal
Copy link

espoal commented Nov 23, 2022

Dear all,

I'm writine some io_uring examples in rust, and I would like to add QUIC. The idea is to try and benchmark some advanced options like batching, zero copy, AF_XDP, eBPF, ....

I guess my best option is to try quinn-proto, as it's advertised for custom event loops. Is there any example, maybe in the tests, maybe a simplified one? Do you think it's doable?

Any advice is welcome, before I will try to dive in the codebase :)

@djc
Copy link
Member

djc commented Nov 23, 2022

Would be great to have this! I think the cool version of this in 0.9 would be to try to implement quinn::AsyncUdpSocket on top of io_ring, but just basic quinn-proto would be nice to. I guess it should be doable? Would be interesting to find out where you hit any snags.

I'd particularly love an implementation on top of tokio-uring.

@Ralith
Copy link
Collaborator

Ralith commented Nov 23, 2022

If you do go with quinn-proto, the discussion on using it in #1441 may be helpful. The async interface is a lot more ergonomic, but may be harder to demonstrate interesting performance results with.

@espoal
Copy link
Author

espoal commented Nov 24, 2022

@djc At some point we will for sure have an implementation in tokio uring, but before that we need to analyze all the io_uring options and decide which opcodes needs to be implemented in tokio. E.g.: Zero copy? It reduces memory bandwidth usage but also increases latency on big packets. Sqpoll? again it reduces CPU usage but increases latency. And many other options to test.
My goal for now is to do a very simple implementation, like this one, that will allow us to have a clearer picture on what are the best practices.

I gave a quick look to quinn::AsyncUdpSocket but still I can't visualize how would I plug it in io_uring. With uring I can read/recv packets, how would I pass them to quinn::AsyncUdpSocket?

@Ralith , thank you for the link that's what I needed, I will try to follow it and then I will make more questions :) Maybe I could build a plain UDP server with all the configuration options, and then ask again for your help. If I understood correctly, I should use quinn_proto::Endpoint::handle with the data I receive from the socket, and then the library will do its magic somehow :D (more investigation needed)

Some more questions:

  • is there a difference for QUIC if I use read/write or send/recv?

@Ralith
Copy link
Collaborator

Ralith commented Nov 25, 2022

QUIC needs a bunch of advanced socket functionality to get optimal behavior out of UDP. In the conventional API, this is only possible using the sendmsg family of functions. See quinn-udp/src/unix.rs for examples. I'm not familiar with the specifics of the operations supported by io_uring, but I'd guess there's a similar distinction there.

@Icelk
Copy link

Icelk commented Mar 27, 2023

Something like this seems feasible. We can actually also send headers to the syscall. It'd however require tokio-uring to open up it's API, so we can send headers.

Then, there's also the problem of tokio-uring giving an opaque future, while we expect poll methods. I guess we'll have to make a generic struct which stores the active future?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants