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

implement SendMsgZc for more efficent tcp socket message passing #333

Open
Vrtgs opened this issue Feb 4, 2025 · 4 comments
Open

implement SendMsgZc for more efficent tcp socket message passing #333

Vrtgs opened this issue Feb 4, 2025 · 4 comments
Labels
F-feature-request feature request

Comments

@Vrtgs
Copy link

Vrtgs commented Feb 4, 2025

Is your feature request related to a problem? Please describe.
In scenarios where we need to send large data buffers over sockets, the existing APIs require additional memory copies, which can lead to inefficiencies in terms of performance, especially in high-throughput applications.

Describe the solution you'd like
an Api as follows

monoio::net::send_message(&mut sock1, &mut sock2);

and

monoio::net::socket_copy_bidirectional(&mut sock1, &mut sock2);

Describe alternatives you've considered
tokio_splice but that doesn't use io_uring, furthermore splice still copies, just not as much as a full read then write

@Vrtgs Vrtgs added the F-feature-request feature request label Feb 4, 2025
@ihciah
Copy link
Member

ihciah commented Feb 5, 2025

In monoio there's splice support. Could you check if it works for your need?

@Vrtgs
Copy link
Author

Vrtgs commented Feb 5, 2025 via email

@ihciah
Copy link
Member

ihciah commented Feb 5, 2025

Here is the splice op: https://github.com/bytedance/monoio/blob/master/monoio/src/io/splice.rs
Here is the copy based on it(but it requires additional syscalls to create pipes so I recommend you to implement it by your own if it is very hot): https://github.com/bytedance/monoio/blob/master/monoio/src/io/util/copy.rs#L75

@Vrtgs
Copy link
Author

Vrtgs commented Feb 7, 2025

Here is the splice op: https://github.com/bytedance/monoio/blob/master/monoio/src/io/splice.rs
Here is the copy based on it(but it requires additional syscalls to create pipes so I recommend you to implement it by your own if it is very hot): https://github.com/bytedance/monoio/blob/master/monoio/src/io/util/copy.rs#L75

Thanks a lot, this does help, but I think this should be documented on docs.rs, because it can't be found there, and there should also be a directional version

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

No branches or pull requests

2 participants