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

perf: improve BufList::copy_to_bytes if len == remaining #112

Merged
merged 1 commit into from
Mar 11, 2024

Conversation

seanmonstar
Copy link
Member

Using take(len) costs a bit in performance. If copying the full thing (which is what Collected::to_bytes() does), we can skip using take(n) and see a significant speed up.

Using hyper's body benchmarks, on my tiny VM, the perf improvement is from 5GB/s to 31GB/s.

@yanns
Copy link

yanns commented Mar 11, 2024

I've tried this change. All tests are passing.

My observation on production-like traffic: tokio-rs/axum#2381 (reply in thread)

@seanmonstar seanmonstar merged commit 76b19e6 into master Mar 11, 2024
5 checks passed
@seanmonstar seanmonstar deleted the to-bytes-without-take branch March 11, 2024 18:53
@seanmonstar
Copy link
Member Author

Published in http-body-util v0.1.1.

@yanns
Copy link

yanns commented Mar 12, 2024

Thanks!
We've updated, and the performance issues are fixed for us.

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