maobaolong commented on code in PR #1918:
URL: 
https://github.com/apache/incubator-uniffle/pull/1918#discussion_r1680903173


##########
server/src/main/java/org/apache/uniffle/server/netty/ShuffleServerNettyHandler.java:
##########
@@ -309,6 +292,37 @@ public void handleSendShuffleDataRequest(TransportClient 
client, SendShuffleData
     client.getChannel().writeAndFlush(rpcResponse);
   }
 
+  private static void releaseBufferMemoryAndMetrics(
+      SendShuffleDataRequest req,
+      String appId,
+      int shuffleId,
+      long requireBufferId,
+      ShuffleBufferManager shuffleBufferManager,
+      PreAllocatedBufferInfo info,
+      boolean isPreAllocated) {
+    if (isPreAllocated) {
+      shuffleBufferManager.releaseMemory(info.getRequireSize(), false, true);
+    }
+    if (MapUtils.isNotEmpty(req.getPartitionToBlocks())) {
+      AtomicLong counter = new AtomicLong(0);
+      // release memory
+      req.getPartitionToBlocks().values().stream()
+          .flatMap(Collection::stream)
+          .forEach(
+              block -> {
+                block.getData().release();
+                counter.getAndAdd(block.getData().readableBytes());
+              });
+      ShuffleServerMetrics.counterTotalReceivedDataSize.inc(counter.get());
+    } else {
+      LOG.error(
+          "Failed to handle send shuffle data request, no blocks this request. 
appId: {}, shuffleId: {}, requireBufferId: {}",

Review Comment:
   done



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