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

[Feature Request] Add io-uring support #580

Open
soyflourbread opened this issue Jul 31, 2021 · 4 comments
Open

[Feature Request] Add io-uring support #580

soyflourbread opened this issue Jul 31, 2021 · 4 comments

Comments

@soyflourbread
Copy link

Tokio recently added tokio-uring, io-uring support for tokio.
io-uring is a new Linux API for asynchronous I/O operations.

io-uring makes filesystem operations truly asynchronous, and avoids epolls for events notification.
Some early tests claimed that by switching to io-uring, the performance of a simple TCP echo server improved by up to 60%.

Although io-uring is only supported on Linux kernel >= 5.6,
adding its support should improve shadowsocks-rust's performance with multiple clients.

@zonyitoo
Copy link
Collaborator

First of all, the benefit of making filesystem operations truly asynchronous won't help in this project, because there is no file operations except reading configuration files.

The improvement of TCP and UDP sockets may help, but the main advantage of io-uring, reducing memory copies in socket I/O, shouldn't make that distinct improvement like a simple TCP echo server.

For AEAD servers, which are the most used configuration among users, we have to handle data stream in chunks and decrypt them to another buffer for reading. There should be a better solution for handling this situation, like passing a huge buffer all the way from the application level and decrypt packets in place preventing excessive buffer copying.

It is worth a try to make it work with tokio-uring if it requires small modification.

But I don't think most of the shadowsocks' users can reach the bottleneck of epoll.

@zonyitoo
Copy link
Collaborator

tokio-uring is a single threaded runtime: https://github.com/tokio-rs/tokio-uring/blob/fe681bf18fdccf28090955b49b1415442bec54d4/src/runtime.rs#L53-L55 .

I would recommend to wait for tokio to adopt it into its built-in multithread runtime.

@zonyitoo
Copy link
Collaborator

After a glance of tokio-uring's code, I think only the File type that it provided can uses the io-uring Runtime, the other tokio based I/O objects uses tokio's built-in current-thread runtime. https://github.com/tokio-rs/tokio-uring/blob/fe681bf18fdccf28090955b49b1415442bec54d4/src/runtime.rs#L53-L55

@KernelErr
Copy link

I wrote a layer 4 proxy named fourth, and I initially tried glommio as its runtime. Glommio is a thread-per-core async runtime based on io_uring, and it supports networking. Its throughput (20Gbps for single-core) can be twice of Tokio. However, its QPS would be much lower. As far as I know, there is still no ideal io_uring runtime for Rust, and a large company in China is working on it. :)

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

No branches or pull requests

3 participants