Skip to content

allocation free AdaptiveByteBuf::setBytes(byte[]) (#16058)#16063

Merged
normanmaurer merged 1 commit into
netty:5.0from
chrisvest:5.0-put-array
Dec 18, 2025
Merged

allocation free AdaptiveByteBuf::setBytes(byte[]) (#16058)#16063
normanmaurer merged 1 commit into
netty:5.0from
chrisvest:5.0-put-array

Conversation

@chrisvest

Copy link
Copy Markdown
Member

Motivation:
The adaptive buffer's setBytes(byte[]) method requires the underlying internal NIO buffer to be materialized, but temporary buffers (which won't get flushed to the network) are not granted to have it, causing an unwanted allocation

Modification:
Java 13 expose ad-hoc method which allow using the root parent NIO buffer, saving materializing the internal NIO buffer.

Result:
Cheaper setBytes

(cherry picked from commit 3cae6f6)

Motivation:
The adaptive buffer's setBytes(byte[]) method requires the underlying
internal NIO buffer to be materialized, but temporary buffers (which
won't get flushed to the network) are not granted to have it, causing an
unwanted allocation

Modification:
Java 13 expose ad-hoc method which allow using the root parent NIO
buffer, saving materializing the internal NIO buffer.

Result:
Cheaper setBytes

(cherry picked from commit 3cae6f6)
@normanmaurer normanmaurer added this to the 5.0.0.Final milestone Dec 18, 2025
@normanmaurer normanmaurer merged commit bfc6eab into netty:5.0 Dec 18, 2025
22 of 23 checks passed
@chrisvest chrisvest deleted the 5.0-put-array branch December 18, 2025 18:41
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.

3 participants