-
Notifications
You must be signed in to change notification settings - Fork 123
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: Use std::io::BufWriter
with a 64KB buffer for dumping data
#1752
Conversation
Let's see if this makes things faster.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1752 +/- ##
=======================================
Coverage 92.97% 92.97%
=======================================
Files 119 119
Lines 37253 37253
=======================================
Hits 34637 34637
Misses 2616 2616 ☔ View full report in Codecov by Sentry. |
Benchmark resultsPerformance differences relative to ef5caeb.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a <BufWriter as Write>::flush
on fin
, right? Otherwise some data might remain in the buffer and measurements are hard to compare.
Probably, although the docs say it is called (just if there is an error that remains unhandled.) |
Co-authored-by: Max Inden <[email protected]> Signed-off-by: Lars Eggert <[email protected]>
That whole "write to file" functionality could be factored out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I combined the suggestions in larseggert#19.
@@ -228,7 +228,7 @@ impl<'b> Handler<'b> { | |||
return Ok(fin); | |||
} | |||
|
|||
if let Some(out_file) = maybe_out_file { | |||
if let Some(ref mut out_file) = maybe_out_file { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if let Some(ref mut out_file) = maybe_out_file { | |
if let Some(out_file) = maybe_out_file { |
ref mut
needed? Compiles for me without.
let mut buf_writer = maybe_out_file | ||
.take() | ||
.map(|file| BufWriter::with_capacity(BUFWRITER_BUFFER_SIZE, file)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why construct a new BufWriter
on each read
call? Shouldn't the BufWriter
be wrapping the File
for the lifetime of the File
? That would be consistent with the http3.rs
implementation.
let buf_writer = | ||
out_file.map(|file| BufWriter::with_capacity(BUFWRITER_BUFFER_SIZE, file)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about moving this into get_output_file
. get_output_file
is called by both http3
and http09
, thus no need for duplication.
Thanks for that, it's the better approach. Can you point the PR at the main repo? |
👍 see #1756. |
Overtaken by #1756 |
Pull request was closed
Let's see if this makes things faster.