-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
reduce allocations of ackhandler.Packet #3525
Conversation
Codecov ReportBase: 85.61% // Head: 85.60% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #3525 +/- ##
==========================================
- Coverage 85.61% 85.60% -0.01%
==========================================
Files 137 137
Lines 10016 10085 +69
==========================================
+ Hits 8575 8633 +58
- Misses 1065 1077 +12
+ Partials 376 375 -1
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. |
0e69b37
to
5f5eea1
Compare
} | ||
// After this point, we must not use ackedPackets any longer! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ackedPackets = nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
var packetPool = sync.Pool{New: func() any { return &Packet{} }} | ||
|
||
func GetPacket() *Packet { | ||
p := packetPool.Get().(*Packet) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming that callers will sanitize data seems dangerous to me, and could leak to cross-connection data leaks. Is there a downside to zeroing out the other struct members here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
At some point it might be nice to reuse the slice in Packet.Frames
, but we're not there yet.
5f5eea1
to
3207222
Compare
3207222
to
a3b91cf
Compare
During a 1 GB transfer, quic-go allocates 500 MB on the sending side, as determined using the
allocs
function of pprof. Of those 500 MB, 140 MB are consumed for theackhandler.Packet
. With this change, we can bring this down to 25 MB.We can easily solve this by:
Packet
by pointer instead of by value in the linked lists used in the ackhandlersync.Pool
to reusePacket
structsBefore:
After: