Skip to content

fix: optimize connection.Read to copy directly from linked buffer#415

Open
xiaost wants to merge 1 commit intomainfrom
fix/conn-read
Open

fix: optimize connection.Read to copy directly from linked buffer#415
xiaost wants to merge 1 commit intomainfrom
fix/conn-read

Conversation

@xiaost
Copy link
Contributor

@xiaost xiaost commented Mar 4, 2026

Add flagReadExposed to track when a node's buffer has been returned directly to user code via zero-copy Reader methods (Next, Peek, Slice, GetBytes).
Connection.Read now uses readCopy which copies from nodes without setting this flag, and only releases nodes that are not exposed.
This preserves buffer validity for prior zero-copy callers until Release.

Add flagReadExposed to track when a node's buffer has been returned
directly to user code via zero-copy Reader methods (Next, Peek, Slice,
GetBytes). Connection.Read now uses readCopy which copies from nodes
without setting this flag, and only releases nodes that are not exposed.
This preserves buffer validity for prior zero-copy callers until Release.
@xiaost xiaost requested review from a team as code owners March 4, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant