XHTTP transport: Replace io.ReadAll with io.ReadFull in ServeHTTP; Simplify uploadWriter.Write#5801
Closed
ozeranskii wants to merge 2 commits intoXTLS:mainfrom
Closed
XHTTP transport: Replace io.ReadAll with io.ReadFull in ServeHTTP; Simplify uploadWriter.Write#5801ozeranskii wants to merge 2 commits intoXTLS:mainfrom
ozeranskii wants to merge 2 commits intoXTLS:mainfrom
Conversation
Replace io.ReadAll grow-and-copy with exact-size io.ReadFull allocations on both client (PostPacket) and server (ServeHTTP) paths. Skip slices.Concat when only one payload source has data. Bound concurrent upload goroutines with a semaphore to limit peak memory. Clean up dead XmuxManager entries from globalDialerMap to prevent unbounded map growth. Simplify uploadWriter removing MultiBufferContainer overhead. Fix double-free in uploadWriter on pipe write error.
…mplify uploadWriter.Write
6 tasks
Member
|
别再开这些AI PR了 我说了我会处理的 |
Contributor
Author
|
@Fangliding Okay, whatever you say. I didn't know this repository wasn't about OSS. I never saw any mention of it being a solo project. No problem. |
Member
|
c1b67a9 加了 co-author |
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
io.ReadAll(io.LimitReader(...))with single exact-size allocation +io.ReadFull, avoiding grow-and-copy pattern that causes unnecessary heap allocations on every POST requestslices.Concatwhen only one payload source has data (the common case forpacket-upmode)uploadWriter.Write- replaceMultiBufferContainerwrapper with directbuf.New()per chunk, remove dead commented-out codeBenchmark (5MB transfer, packet-up, HTTP/1.1)
Server-side
io.ReadFullwith exact-size pre-allocation eliminatesio.ReadAll's repeated grow-and-copy on each POST body read.Relates to #5344, #5797