waitinfuture commented on code in PR #2461:
URL: https://github.com/apache/celeborn/pull/2461#discussion_r1571620328


##########
client-spark/common/src/main/java/org/apache/spark/shuffle/celeborn/SortBasedPusher.java:
##########
@@ -339,24 +339,50 @@ private void growPointerArrayIfNecessary() throws 
IOException {
       }
 
       long used = inMemSorter.getMemoryUsage();
+      long requestedBytes = used / 8 * 2;
+      int allocateMemoryRetryCount = 0;
+      int maxMemoryAllocationRetry = 3;
       LongArray array = null;
-      try {
-        // could trigger spilling
-        array = allocateArray(used / 8 * 2);
-      } catch (TooLargePageException e) {
-        // The pointer array is too big to fix in a single page, spill.
-        logger.info(
-            "Pushdata in growPointerArrayIfNecessary, memory used {}",
-            Utils.bytesToString(getUsed()));
-        pushData(true);
-      } catch (SparkOutOfMemoryError rethrow) {
-        // should have trigger spilling
-        if (inMemSorter.numRecords() > 0) {
-          logger.error("OOM, unable to grow the pointer array");
-          throw rethrow;
+      boolean cont = true;
+      while (allocateMemoryRetryCount < maxMemoryAllocationRetry && cont) {
+        try {
+          // could trigger spilling
+          logger.info("asking for " + requestedBytes + " more bytes to 
accommodate more records");
+          array = allocateArray(used / 8 * 2);

Review Comment:
   IIUC the intention is to use `requestedBytes` instead of `used / 8 * 2` here?



##########
client-spark/common/src/main/java/org/apache/spark/shuffle/celeborn/SortBasedPusher.java:
##########
@@ -339,24 +339,50 @@ private void growPointerArrayIfNecessary() throws 
IOException {
       }
 
       long used = inMemSorter.getMemoryUsage();
+      long requestedBytes = used / 8 * 2;
+      int allocateMemoryRetryCount = 0;
+      int maxMemoryAllocationRetry = 3;
       LongArray array = null;
-      try {
-        // could trigger spilling
-        array = allocateArray(used / 8 * 2);
-      } catch (TooLargePageException e) {
-        // The pointer array is too big to fix in a single page, spill.
-        logger.info(
-            "Pushdata in growPointerArrayIfNecessary, memory used {}",
-            Utils.bytesToString(getUsed()));
-        pushData(true);
-      } catch (SparkOutOfMemoryError rethrow) {
-        // should have trigger spilling
-        if (inMemSorter.numRecords() > 0) {
-          logger.error("OOM, unable to grow the pointer array");
-          throw rethrow;
+      boolean cont = true;

Review Comment:
   Better to use `continue` for easy understanding



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

Reply via email to