Pool hot-path ARQ buffers to reduce per-packet allocations#131
Open
Isusami wants to merge 1 commit intomasterking32:mainfrom
Open
Pool hot-path ARQ buffers to reduce per-packet allocations#131Isusami wants to merge 1 commit intomasterking32:mainfrom
Isusami wants to merge 1 commit intomasterking32:mainfrom
Conversation
Introduce sync.Pool-backed arqDataPool with getARQBuffer/putARQBuffer for data, control, and rx payload buffers. Each struct gains a pool pointer (dataPoolBuf, payloadPoolBuf, poolBuf) for deterministic release. Fixes a pooled buffer leak on duplicate control packet early return in SendControlPacketWithTTL.
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.
Summary
Introduce
sync.Pool-backed buffer pooling for ARQ data, control, and rx payload buffers to reduce per-packet heap allocations on hot paths.Changes
arqDataPoolwithgetARQBuffer/putARQBufferfor reusable[]bytebuffersdataPoolBuf,payloadPoolBuf,poolBuf) toarqDataItem,arqControlItem, andrxPayloadfor deterministic releaseSendControlPacketWithTTLWhy
Every packet currently allocates fresh
[]byteslices that become GC pressure under load. Pooling reuses buffers across packets, reducing allocation churn on the critical data plane.Test plan
go test ./internal/arq/...-- all 50+ tests passTestARQ_FinHandshakeWaitsForInboundWriteDrain(test logger, not production code) -- same onmain