rickyma commented on code in PR #1521:
URL: 
https://github.com/apache/incubator-uniffle/pull/1521#discussion_r1487190210


##########
common/src/main/java/org/apache/uniffle/common/netty/protocol/Decoders.java:
##########
@@ -47,8 +46,7 @@ public static ShuffleBlockInfo decodeShuffleBlockInfo(ByteBuf 
byteBuf) {
     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);

Review Comment:
   `ByteBuf` will not be splitted into multiple parts. It will be used by a 
`SendShuffleDataRequest` as a whole.
   It will not bring errors. Because we `retain` the `ByteBuf`(`refCnf`++) 
everytime when we do a `readSlice`.
   
   ```
   public static SendShuffleDataRequest decode(ByteBuf byteBuf) {
       long requestId = byteBuf.readLong();
       String appId = ByteBufUtils.readLengthAndString(byteBuf);
       int shuffleId = byteBuf.readInt();
       long requireId = byteBuf.readLong();
       Map<Integer, List<ShuffleBlockInfo>> partitionToBlocks = 
decodePartitionData(byteBuf);
       long timestamp = byteBuf.readLong();
       return new SendShuffleDataRequest(
           requestId, appId, shuffleId, requireId, partitionToBlocks, 
timestamp);
     }
   ```
   
   But it might slow down the flushing process.
   Because it will not trigger the actual flushing process util all the 
`ShufflePartitionedData` is flushed(refCnt decreased to 0):
   
   ```
   List<ShufflePartitionedData> shufflePartitionedData = 
toPartitionedData(sendShuffleDataRequest);
   ...
   for (ShufflePartitionedData spd : shufflePartitionedData) {
       ...
       ret = manager.cacheShuffleData(appId, shuffleId, isPreAllocated, spd);
       ...
   }
   ```
   
   So maybe we can hold this PR and find a better way to do this.



-- 
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]

Reply via email to