Reuse the sent packet deque across sendFrames calls - #58
Open
glbrntt wants to merge 1 commit into
Open
Conversation
glbrntt
requested review from
agnosticdev,
kkuk24,
rpaulo and
tfpauly
as code owners
July 28, 2026 08:46
Contributor
Author
|
When running some http/3 benchmarks (100k requests, each a 1k download with 100 concurrent streams on one connection) this saves 100k allocs (only ~2% or so), but reduces total bytes allocated by ~15%. |
Motivation: Both sendFrames() overloads create a new deque of SentPacketRecord on every call, only to hand its contents to recovery and throw the storage away. Modifications: - Store a deque on the QUICConnection and reuse it. - Take 'sentPackets' inout rather than consuming in Recovery.recordSentPackets. It already drained the storage in place so now the connection can reuse the empty deque. Result: - Fewer allocations
glbrntt
force-pushed
the
reuse-packet-deque
branch
from
July 28, 2026 14:22
1ca3472 to
32fe031
Compare
rpaulo
reviewed
Jul 28, 2026
| // 'sentPackets' is held onto for the lifetime of the connection. If a send burst grows it | ||
| // beyond a certain limit then drop the capacity. This avoids bursty traffic bloating memory | ||
| // indefinitely. | ||
| if self.sentPackets.capacity > 512 { |
Contributor
There was a problem hiding this comment.
This should be a setting in Preferences.swift
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.
Motivation:
Both sendFrames() overloads create a new deque of SentPacketRecord on every call, only to hand its contents to recovery and throw the storage away.
Modifications:
Result: