From 7d97c5b6def46af8f2185a6a8430e14aa59ace4c Mon Sep 17 00:00:00 2001 From: Chao Sun Date: Tue, 12 Mar 2024 10:28:02 -0700 Subject: [PATCH] fix: Peak memory usage should include active spiller --- .../apache/spark/shuffle/sort/CometShuffleExternalSorter.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spark/src/main/java/org/apache/spark/shuffle/sort/CometShuffleExternalSorter.java b/spark/src/main/java/org/apache/spark/shuffle/sort/CometShuffleExternalSorter.java index aa806e2e81..ed0cfa9631 100644 --- a/spark/src/main/java/org/apache/spark/shuffle/sort/CometShuffleExternalSorter.java +++ b/spark/src/main/java/org/apache/spark/shuffle/sort/CometShuffleExternalSorter.java @@ -257,6 +257,7 @@ private long getMemoryUsage() { for (SpillSorter sorter : spillingSorters) { totalPageSize += sorter.getMemoryUsage(); } + totalPageSize += activeSpillSorter.getMemoryUsage(); return totalPageSize; } @@ -274,6 +275,7 @@ public long getPeakMemoryUsedBytes() { } private long freeMemory() { + updatePeakMemoryUsed(); long memoryFreed = 0; if (isAsync) { for (SpillSorter sorter : spillingSorters) {