Skip to content

feat: introduce zero_copy_from_pipe() and zero_copy_to_pipe() - #352

Open
kaspar030 wants to merge 1 commit into
monoio-rs:masterfrom
kaspar030:zerocopy_direct_pipe
Open

feat: introduce zero_copy_from_pipe() and zero_copy_to_pipe()#352
kaspar030 wants to merge 1 commit into
monoio-rs:masterfrom
kaspar030:zerocopy_direct_pipe

Conversation

@kaspar030

Copy link
Copy Markdown
Contributor

#351 brought my monoio version of yes | netcat -l -p 1234 to 80% of the expected performance, but that's not where a high performance Rust library can stop.

Looking at the code, I realized that zero_copy() always creates a new Pipe. If either the reader or the writer is already a Pipe, this is not necessary.

This PR adds two functions for those cases. Together with #351, monoio now matches yes | netcat ....
Without #351, this almost doubles the performance (~160MiB/s -> ~310MiB/s) on my box, but the use case really needs the larger buffer.

@kaspar030
kaspar030 force-pushed the zerocopy_direct_pipe branch 2 times, most recently from b55416d to d25ed46 Compare July 14, 2025 06:53
Signed-off-by: Kaspar Schleiser <kaspar@schleiser.de>
@kaspar030
kaspar030 force-pushed the zerocopy_direct_pipe branch from 43ac294 to b15d3c3 Compare October 14, 2025 07:48
@oech3 oech3 mentioned this pull request May 11, 2026
@oech3

oech3 commented Jun 10, 2026

Copy link
Copy Markdown

@kaspar030 Would you compare yes from https://github.com/uutils/coreutils/releases/tag/latest-commit and your monoio copy function with pv from "main branch" on your PC?

In my experience, omitting middler pipe makes slower by unknown reason.

@oech3

oech3 commented Jun 10, 2026

Copy link
Copy Markdown

I think monoio' zero_copy() is not extending pipe size to 1 MiB by fcntl call.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants