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

serialize frames by appending to a byte slice, not to a bytes.Buffer #3530

Merged
merged 3 commits into from Aug 29, 2022

Conversation

marten-seemann
Copy link
Member

The allocation of the bytes.Buffer in the packet packer causes ~32 MB of allocations for sending of 1 GB of application data:
https://github.com/lucas-clemente/quic-go/blob/07412be8a02ef0e55580ebf8db9c38a759c0a0e5/packet_packer.go#L828

Instead of allocating to a bytes.Buffer, we can just append to a []byte.

This PR doesn't remove the allocation of the bytes.Buffer, since the header serializer still needs it. As part of the effort to refactor our header handling, we'll change this, at least for Short Header packets.

@marten-seemann marten-seemann added this to the v0.30.0 milestone Aug 28, 2022
@codecov
Copy link

codecov bot commented Aug 28, 2022

Codecov Report

Base: 85.61% // Head: 85.66% // Increases project coverage by +0.05% 🎉

Coverage data is based on head (ab6d664) compared to base (07412be).
Patch coverage: 95.16% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3530      +/-   ##
==========================================
+ Coverage   85.61%   85.66%   +0.05%     
==========================================
  Files         137      137              
  Lines       10016    10029      +13     
==========================================
+ Hits         8575     8591      +16     
+ Misses       1065     1063       -2     
+ Partials      376      375       -1     
Impacted Files Coverage Δ
packet_packer.go 84.55% <63.64%> (+0.09%) ⬆️
server.go 81.16% <80.00%> (+0.05%) ⬆️
internal/wire/new_connection_id_frame.go 94.59% <87.50%> (ø)
internal/wire/ack_frame.go 94.78% <100.00%> (ø)
internal/wire/connection_close_frame.go 94.74% <100.00%> (ø)
internal/wire/crypto_frame.go 95.45% <100.00%> (ø)
internal/wire/data_blocked_frame.go 100.00% <100.00%> (ø)
internal/wire/datagram_frame.go 95.12% <100.00%> (ø)
internal/wire/handshake_done_frame.go 100.00% <100.00%> (+50.00%) ⬆️
internal/wire/max_data_frame.go 100.00% <100.00%> (ø)
... and 14 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@marten-seemann marten-seemann changed the title when serializing frames, append to a byte slice, not to bytes.Buffer serialize frames by appending to a byte slice, not to a bytes.Buffer Aug 28, 2022
@marten-seemann marten-seemann merged commit ec9c824 into master Aug 29, 2022
@marten-seemann marten-seemann deleted the frame-append-to-slice branch August 29, 2022 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants