Conversation
A queue drained through `drainArrayKeepingCapacity` holds an empty buffer on purpose. Adopting the incoming storage whenever this side is empty threw that buffer away and took a smaller one, so the next batch reallocated. Adopt the incoming storage only when this side would otherwise have to grow. Measured on my Mac against `main` with the package's QUIC benchmark tools. Allocation counts come from full malloc stack logging, which records every allocation: QUICTransfer -size 1200, per message 24.37 -> 23.38 QUICTransfer, per 500 KB transfer 6,187.6 -> 6,177.1 QUICHandshake, per connection 1,947.4 -> 1,944.9 QUICStreamLoad, per stream 111.8 -> 112.2 The saving depends on timing: it only applies when the queue has drained by the time the next batch arrives, which happened about once per message here. Wall-clock time comes from running `main`, this change and the other changes measured alongside it in a rotating order for 9 rounds, and comparing each run with `main`'s in the same round. Changes moved paths they do not touch by up to about 1.3%, so differences that size count as noise. Nothing changed beyond noise.
tfpauly
approved these changes
Oct 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A queue drained through
drainArrayKeepingCapacityholds an empty buffer onpurpose. Adopting the incoming storage whenever this side is empty threw that
buffer away and took a smaller one, so the next batch reallocated. Adopt the
incoming storage only when this side would otherwise have to grow.
Measured on my Mac against
mainwith the package's QUIC benchmark tools.Allocation counts come from full malloc stack logging, which records every
allocation:
The saving depends on timing: it only applies when the queue has drained by the
time the next batch arrives, which happened about once per message here.
Wall-clock time comes from running
main, this change and the other changesmeasured alongside it in a rotating order for 9 rounds, and comparing each run
with
main's in the same round. Changes moved paths they do not touch by up toabout 1.3%, so differences that size count as noise. Nothing changed beyond
noise.