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

feat: add with_capacity for ReaderStream #4086

Merged
merged 1 commit into from
Sep 2, 2021

Conversation

ttys3
Copy link
Contributor

@ttys3 ttys3 commented Aug 31, 2021

Motivation

I try to build a static file server with axum + tower-http, and decide to improve tower-http's file sending speed with tokio-util's ReaderStream.

But did not find a way to cutomized the buf chunk size.

With tokio-util's default 4096 buf chunk size, the static server can only stable at 50MiB/s

so I try to increase the buf chunk size to 8K, 32K, 64K and the speed got improved to > 200MiB/s

but by default, there's no with_capacity method, so I have to use crate patch.

Solution

add with_capacity

Related

#2215

@Darksonn Darksonn added A-tokio-util Area: The tokio-util crate M-io Module: tokio/io labels Sep 1, 2021
@ttys3 ttys3 force-pushed the io_readerstream_with_capacity branch from 1ff309b to 467d3d3 Compare September 1, 2021 17:49
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@ttys3
Copy link
Contributor Author

ttys3 commented Sep 2, 2021

CI / test tokio full --unstable (macos-latest) (pull_request) Cancelled after 360m, need a restart ?

@ttys3 ttys3 requested a review from Darksonn September 2, 2021 05:49
@Darksonn Darksonn merged commit d0dd74a into tokio-rs:master Sep 2, 2021
@ttys3 ttys3 deleted the io_readerstream_with_capacity branch September 2, 2021 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio-util Area: The tokio-util crate M-io Module: tokio/io
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants