Skip to content

Shrink the receive read buffer from 16 MB to 64 KiB - #11

Open
Atsika wants to merge 1 commit into
mainfrom
perf/read-buffer-size
Open

Shrink the receive read buffer from 16 MB to 64 KiB#11
Atsika wants to merge 1 commit into
mainfrom
perf/read-buffer-size

Conversation

@Atsika

@Atsika Atsika commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

Last item from the deferred list in the stream-integrity round.

The 16 MB read buffer in ReceiveLoop dates from before record reassembly existed, when a single Read had to swallow a whole record or lose its tail. Since acc now 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 Read handles a caller buffer smaller than a frame by copying min(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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant