serialize frames by appending to a byte slice, not to a bytes.Buffer #3530
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.