GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||
GeezerVison is showing github.com — Avoid buffer duplication in AdaptiveByteBuf.setBytes by chrisvest · Pull Request #15728 · netty/netty Conversation
|
|
This addresses the duplicate calls. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I was a bit afraid to do this since a recent bug on getBytes in Http 1.1 while performing string encoding/decoding. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
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 Co-authored-by: Chris Vest <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Adaptive's buffers setBytes performance is held back by NIO Buffers allocations
There was an error while loading. Please reload this page.