Improve ARQ/LZ4 allocation efficiency and harden DNS parser limits#129
Closed
Isusami wants to merge 3 commits intomasterking32:mainfrom
Closed
Improve ARQ/LZ4 allocation efficiency and harden DNS parser limits#129Isusami wants to merge 3 commits intomasterking32:mainfrom
Isusami wants to merge 3 commits intomasterking32:mainfrom
Conversation
5cf13ec to
5833944
Compare
Pool hot-path ARQ and LZ4 buffers to cut per-packet allocations, cap DNS section counts before allocation, remove retransmit panic recovery so critical failures surface instead of being masked, and fix pooled buffer leak on duplicate control packet early return.
986172e to
d7233b0
Compare
When stream IDs are rapidly recycled, re-remembering pushes new heap entries while stale ones remain, causing the heap to grow up to ~1.9x the map size. Add compactRecentlyClosedHeapLocked to rebuild the heap from the authoritative map when it exceeds 1.5x, bounding peak memory.
d512f50 to
0df3a8e
Compare
…trace The pooling refactor accidentally removed the panic recovery wrapper in retransmitLoop. Without it a panic in checkRetransmits kills the goroutine silently, leaving streams without retransmissions. The original recovery logged at Debug level which effectively swallowed panics; this version logs at Error with a full goroutine stack trace for diagnosability.
ea96bab to
f0d0119
Compare
Owner
|
درود، |
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
dnsparserto prevent oversized allocations from malformed packets.recover()in ARQ retransmit loop fromDebugf(silent) toErrorfwith full goroutine stack trace for diagnosability.SendControlPacketWithTTL.recentlyClosedHeapto prevent stale entry accumulation when stream IDs are rapidly recycled (heap bounded to 1.5x map size).Why
These changes address performance/reliability issues:
Test Plan
All 17 packages with tests pass with
-race:cmd/clientinternal/arqinternal/basecodecinternal/clientinternal/client/handlersinternal/compressioninternal/configinternal/dnscacheinternal/dnsparserinternal/domainmatcherinternal/enumsinternal/fragmentstoreinternal/loggerinternal/mlqinternal/securityinternal/socksprotointernal/vpnprotoAdditional verification:
TestRecentlyClosedHeapStaleEntryGrowth— confirms heap stays within 1.5x bound after 10 cycles of 50 recycled stream IDsPre-existing issue (not introduced by this PR)
internal/udpserver:TestProcessDeferredStreamSynDoesNotAttachAfterCancellationandTestProcessDeferredSOCKS5SynDoesNotAttachAfterCancellationhave a data race ontestNetConn.closed(plainboolread/written across goroutines without synchronization). Confirmed identical failure onmainbranch — not a regression.