You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/02/17 18:56:25 UTC

[GitHub] [spark] dongjoon-hyun commented on a change in pull request #35559: [SPARK-33206] Fix shuffle index cache weight calculation for small index files

dongjoon-hyun commented on a change in pull request #35559:
URL: https://github.com/apache/spark/pull/35559#discussion_r809369318



##########
File path: common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/ExternalShuffleBlockResolver.java
##########
@@ -118,9 +118,17 @@ public ShuffleIndexInformation load(File file) throws IOException {
             return new ShuffleIndexInformation(file);
           }
         };
+
+    // SPARK-33206: weightCorrection is a constant to increase the shuffle index weight for the
+    // index cache to avoid underestimating the retained memory size coming from the bookkeeping
+    // objects in case of very small index files (i.e files with two offsets are only 16 bytes
+    // in size but related bookkeeping objects retained memory is 1192 bytes) otherwise we can
+    // easily cause an OOM in the NodeManager even when the default cache size limit is used.
+    final int weightCorrection = 1176;
     shuffleIndexCache = CacheBuilder.newBuilder()
       .maximumWeight(JavaUtils.byteStringAsBytes(indexCacheSize))
-      .weigher((Weigher<File, ShuffleIndexInformation>) (file, indexInfo) -> indexInfo.getSize())
+      .weigher((Weigher<File, ShuffleIndexInformation>)
+        (file, indexInfo) -> indexInfo.getSize() + weightCorrection)

Review comment:
       Your find looks useful. Why don't we add a new method to `ShuffleIndexInformation` for the future?

##########
File path: common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/ExternalShuffleBlockResolver.java
##########
@@ -118,9 +118,17 @@ public ShuffleIndexInformation load(File file) throws IOException {
             return new ShuffleIndexInformation(file);
           }
         };
+
+    // SPARK-33206: weightCorrection is a constant to increase the shuffle index weight for the
+    // index cache to avoid underestimating the retained memory size coming from the bookkeeping
+    // objects in case of very small index files (i.e files with two offsets are only 16 bytes
+    // in size but related bookkeeping objects retained memory is 1192 bytes) otherwise we can
+    // easily cause an OOM in the NodeManager even when the default cache size limit is used.
+    final int weightCorrection = 1176;
     shuffleIndexCache = CacheBuilder.newBuilder()
       .maximumWeight(JavaUtils.byteStringAsBytes(indexCacheSize))
-      .weigher((Weigher<File, ShuffleIndexInformation>) (file, indexInfo) -> indexInfo.getSize())
+      .weigher((Weigher<File, ShuffleIndexInformation>)
+        (file, indexInfo) -> indexInfo.getSize() + weightCorrection)

Review comment:
       Your finding looks useful. Why don't we add a new method to `ShuffleIndexInformation` for the future?




-- 
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: reviews-unsubscribe@spark.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org