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: Use std::io::BufWriter with a 64KB buffer for dumping data #1752

Closed
wants to merge 7 commits into from

Conversation

larseggert
Copy link
Collaborator

Let's see if this makes things faster.

@larseggert larseggert marked this pull request as draft March 16, 2024 05:32
Copy link

codecov bot commented Mar 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.97%. Comparing base (ef5caeb) to head (12af7c7).

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.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Mar 16, 2024

Benchmark results

Performance differences relative to ef5caeb.

  • coalesce_acked_from_zero 1+1 entries
    time: [193.43 ns 193.91 ns 194.42 ns]
    change: [-0.2698% +0.2948% +0.7795%] (p = 0.29 > 0.05)
    No change in performance detected.

  • coalesce_acked_from_zero 3+1 entries
    time: [235.94 ns 236.53 ns 237.23 ns]
    change: [-0.3898% +0.0346% +0.4613%] (p = 0.88 > 0.05)
    No change in performance detected.

  • coalesce_acked_from_zero 10+1 entries
    time: [235.69 ns 236.58 ns 237.62 ns]
    change: [-0.6618% -0.0811% +0.5301%] (p = 0.79 > 0.05)
    No change in performance detected.

  • coalesce_acked_from_zero 1000+1 entries
    time: [213.99 ns 214.17 ns 214.37 ns]
    change: [-10.280% -3.6253% +0.4736%] (p = 0.35 > 0.05)
    No change in performance detected.

  • RxStreamOrderer::inbound_frame()
    time: [120.45 ms 120.54 ms 120.63 ms]
    change: [+0.2043% +0.3029% +0.3933%] (p = 0.00 < 0.05)
    Change within noise threshold.

  • transfer/Run multiple transfers with varying seeds
    time: [116.42 ms 116.74 ms 117.05 ms]
    thrpt: [34.172 MiB/s 34.265 MiB/s 34.358 MiB/s]
    change:
    time: [-1.6658% -1.3134% -0.9705%] (p = 0.00 < 0.05)
    thrpt: [+0.9800% +1.3309% +1.6940%]
    Change within noise threshold.

  • transfer/Run multiple transfers with the same seed
    time: [117.11 ms 117.28 ms 117.45 ms]
    thrpt: [34.057 MiB/s 34.107 MiB/s 34.155 MiB/s]
    change:
    time: [-1.3857% -1.1836% -0.9796%] (p = 0.00 < 0.05)
    thrpt: [+0.9893% +1.1978% +1.4052%]
    Change within noise threshold.

⬇️ Download logs

@larseggert larseggert marked this pull request as ready for review March 16, 2024 06:04
Copy link
Collaborator

@mxinden mxinden left a 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.

@larseggert
Copy link
Collaborator Author

Probably, although the docs say it is called (just if there is an error that remains unhandled.)

neqo-bin/src/bin/client/http3.rs Outdated Show resolved Hide resolved
@larseggert
Copy link
Collaborator Author

That whole "write to file" functionality could be factored out.

Copy link
Collaborator

@mxinden mxinden left a 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 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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.

Comment on lines +256 to +258
let mut buf_writer = maybe_out_file
.take()
.map(|file| BufWriter::with_capacity(BUFWRITER_BUFFER_SIZE, file));
Copy link
Collaborator

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.

Comment on lines +258 to +259
let buf_writer =
out_file.map(|file| BufWriter::with_capacity(BUFWRITER_BUFFER_SIZE, file));
Copy link
Collaborator

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.

@larseggert
Copy link
Collaborator Author

Thanks for that, it's the better approach. Can you point the PR at the main repo?

@mxinden
Copy link
Collaborator

mxinden commented Mar 17, 2024

Thanks for that, it's the better approach. Can you point the PR at the main repo?

👍 see #1756.

@larseggert
Copy link
Collaborator Author

Overtaken by #1756

@larseggert larseggert closed this Mar 17, 2024
auto-merge was automatically disabled March 17, 2024 20:35

Pull request was closed

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