This is an automated email from the ASF dual-hosted git repository.

roryqi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-uniffle.git


The following commit(s) were added to refs/heads/master by this push:
     new 7fbe7c9f8 [#1472][part-2] fix(server): Reuse ByteBuf when decoding 
shuffle blocks instead of reallocating it (#1521)
7fbe7c9f8 is described below

commit 7fbe7c9f8deb3d9deb7e0961a6f2eba1adf7a0fb
Author: RickyMa <[email protected]>
AuthorDate: Thu Feb 15 12:00:18 2024 +0800

    [#1472][part-2] fix(server): Reuse ByteBuf when decoding shuffle blocks 
instead of reallocating it (#1521)
    
    ### What changes were proposed in this pull request?
    
    Reuse ByteBuf when decoding shuffle blocks instead of reallocating it
    
    ### Why are the changes needed?
    
    A sub PR for: https://github.com/apache/incubator-uniffle/pull/1519
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Existing UTs.
---
 .../main/java/org/apache/uniffle/common/netty/protocol/Decoders.java  | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git 
a/common/src/main/java/org/apache/uniffle/common/netty/protocol/Decoders.java 
b/common/src/main/java/org/apache/uniffle/common/netty/protocol/Decoders.java
index b8c687ce7..54924788c 100644
--- 
a/common/src/main/java/org/apache/uniffle/common/netty/protocol/Decoders.java
+++ 
b/common/src/main/java/org/apache/uniffle/common/netty/protocol/Decoders.java
@@ -28,7 +28,6 @@ import org.apache.uniffle.common.BufferSegment;
 import org.apache.uniffle.common.ShuffleBlockInfo;
 import org.apache.uniffle.common.ShuffleServerInfo;
 import org.apache.uniffle.common.util.ByteBufUtils;
-import org.apache.uniffle.common.util.NettyUtils;
 
 public class Decoders {
   public static ShuffleServerInfo decodeShuffleServerInfo(ByteBuf byteBuf) {
@@ -47,8 +46,7 @@ public class Decoders {
     long crc = byteBuf.readLong();
     long taskAttemptId = byteBuf.readLong();
     int dataLength = byteBuf.readInt();
-    ByteBuf data = 
NettyUtils.getNettyBufferAllocator().directBuffer(dataLength);
-    data.writeBytes(byteBuf, dataLength);
+    ByteBuf data = byteBuf.retain().readSlice(dataLength);
     int lengthOfShuffleServers = byteBuf.readInt();
     List<ShuffleServerInfo> serverInfos = Lists.newArrayList();
     for (int k = 0; k < lengthOfShuffleServers; k++) {

Reply via email to