wForget commented on code in PR #2732:
URL: https://github.com/apache/uniffle/pull/2732#discussion_r2852049617
##########
common/src/main/java/org/apache/uniffle/common/netty/buffer/NettyManagedBuffer.java:
##########
@@ -45,6 +48,20 @@ public ByteBuf byteBuf() {
@Override
public ByteBuffer nioByteBuffer() {
+ // CompositeByteBuf.nioBuffer will return a heap buffer if the composite
buffer has more than one component, even
+ // if all components are direct buffers. In native client scenarios (like
gluten), we prefer to use direct buffer
+ // to reduce data copying.
+ if (buf instanceof CompositeByteBuf && buf.isDirect() &&
buf.nioBufferCount() > 1
+ && NettyUtils.preferDirectForCompositeBuffer()) {
+ int length = buf.readableBytes();
+ ByteBuffer merged = ByteBuffer.allocateDirect(length).order(buf.order());
Review Comment:
Although this still involves one data copy, it is an improvement for gluten
scenarios.
+ Before, there were two data copies: Netty direct buffer → NIO heap buffer
→ Gluten native side.
+ After, there is only one data copy: Netty direct buffer → NIO direct
buffer → Gluten native side (no copy).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]