Skip to content

Conversation

@normanmaurer
Copy link
Member

Motivation:
The setBytes methods are mutating methods, and therefor not thread-safe. The pooling allocator do not protect the position of its internal NIO buffer in these methods, which means it does not call duplicate on the buffer before using it. The adaptive allocator can make the same optimization.

Modification:
Remove ByteBuffer.duplicate calls from the setBytes methods of the AdaptiveByteBuf.

Result:
No more unnecessary ByteBuffer allocation when calling these methods, so the performance should now be on par with the pooling allocator.

Fixes #15723

Motivation:
The setBytes methods are mutating methods, and therefor not thread-safe.
The pooling allocator do not protect the position of its internal NIO
buffer in these methods, which means it does not call duplicate on the
buffer before using it. The adaptive allocator can make the same
optimization.

Modification:
Remove ByteBuffer.duplicate calls from the setBytes methods of the
AdaptiveByteBuf.

Result:
No more unnecessary ByteBuffer allocation when calling these methods, so
the performance should now be on par with the pooling allocator.

Fixes #15723
@normanmaurer normanmaurer added this to the 4.1.128.Final milestone Sep 30, 2025
@normanmaurer normanmaurer merged commit d9a8b00 into 4.1 Sep 30, 2025
16 of 18 checks passed
@normanmaurer normanmaurer deleted the adapt_set branch September 30, 2025 14:25
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.

2 participants