You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@uniffle.apache.org by GitBox <gi...@apache.org> on 2022/08/15 06:19:44 UTC

[GitHub] [incubator-uniffle] summaryzb commented on a diff in pull request #157: [Improvement]record split across writer buffer to save memory

summaryzb commented on code in PR #157:
URL: https://github.com/apache/incubator-uniffle/pull/157#discussion_r945450041


##########
client-spark/common/src/main/java/org/apache/spark/shuffle/writer/WriterBuffer.java:
##########
@@ -39,35 +39,34 @@ public WriterBuffer(int bufferSize) {
   }
 
   public void addRecord(byte[] recordBuffer, int length) {
-    if (askForMemory(length)) {
-      // buffer has data already, add buffer to list
-      if (nextOffset > 0) {
-        buffers.add(new WrappedBuffer(buffer, nextOffset));
-        nextOffset = 0;
-      }
-      if (length > bufferSize) {
-        buffer = new byte[length];
-        memoryUsed += length;
-      } else {
-        buffer = new byte[bufferSize];
-        memoryUsed += bufferSize;
-      }
+    int require = calculateMemoryCost(length);
+    int hasCopied = 0;
+    if (require > 0 && buffer != null && buffer.length - nextOffset > 0) {

Review Comment:
   Follow this suggestion



-- 
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: issues-unsubscribe@uniffle.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org