diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorter.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorter.java b/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorter.java index 66a77982ad..3c1cd39dc2 100644 --- a/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorter.java +++ b/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorter.java @@ -75,6 +75,7 @@ public final class UnsafeExternalSorter extends MemoryConsumer { private MemoryBlock currentPage = null; private long pageCursor = -1; private long peakMemoryUsedBytes = 0; + private long totalSpillBytes = 0L; private volatile SpillableIterator readingIterator = null; public static UnsafeExternalSorter createWithExistingInMemorySorter( @@ -215,7 +216,7 @@ public final class UnsafeExternalSorter extends MemoryConsumer { // we might not be able to get memory for the pointer array. taskContext.taskMetrics().incMemoryBytesSpilled(spillSize); - + totalSpillBytes += spillSize; return spillSize; } @@ -246,6 +247,13 @@ public final class UnsafeExternalSorter extends MemoryConsumer { return peakMemoryUsedBytes; } + /** + * Return the total number of bytes that has been spilled into disk so far. + */ + public long getSpillSize() { + return totalSpillBytes; + } + @VisibleForTesting public int getNumberOfAllocatedPages() { return allocatedPages.size(); @@ -499,6 +507,8 @@ public final class UnsafeExternalSorter extends MemoryConsumer { released += inMemSorter.getMemoryUsage(); inMemSorter.free(); inMemSorter = null; + taskContext.taskMetrics().incMemoryBytesSpilled(released); + totalSpillBytes += released; return released; } } |