Shrink the receive read buffer from 16 MB to 64 KiB - #11
Open
Atsika wants to merge 1 commit into
Open
Conversation
The 16 MB read buffer dates from before record reassembly existed, when a read had to swallow a whole record or lose its tail. ReceiveLoop now accumulates across reads, so the read size only decides how many iterations a large payload takes; framing is unaffected at any size, which the reassembly test asserts down to a single byte per read. aznet's Read handles a caller buffer smaller than a frame by returning a partial copy and draining the remainder on the next call, so a small buffer costs extra copies, not correctness. The allocation is per handler, so the proxy was reserving 16 MB per connected agent, and the agent 16 MB for one transport.
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.
Last item from the deferred list in the stream-integrity round.
The 16 MB read buffer in
ReceiveLoopdates from before record reassembly existed, when a singleReadhad to swallow a whole record or lose its tail. Sinceaccnow reassembles across reads, the read size only decides how many iterations a large payload takes — framing is unaffected at any size, which the reassembly test already asserts down to one byte per read.aznet's
Readhandles a caller buffer smaller than a frame by copyingmin(frameLen, len(p))and draining the remainder on the next call, so a smaller buffer costs extra copies, never bytes.The allocation is per handler: the proxy was reserving 16 MB per connected agent.
Verified:
go build ./...,go vet ./...,go test ./... -race -count=1, and the wasm agent build.