WangGuangxin commented on a change in pull request #28780:
URL: https://github.com/apache/spark/pull/28780#discussion_r443451092



##########
File path: 
core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorter.java
##########
@@ -104,11 +104,13 @@ public static UnsafeExternalSorter 
createWithExistingInMemorySorter(
       int initialSize,
       long pageSizeBytes,
       int numElementsForSpillThreshold,
-      UnsafeInMemorySorter inMemorySorter) throws IOException {
+      UnsafeInMemorySorter inMemorySorter,
+      long existingMemoryConsumption) throws IOException {
     UnsafeExternalSorter sorter = new UnsafeExternalSorter(taskMemoryManager, 
blockManager,
       serializerManager, taskContext, recordComparatorSupplier, 
prefixComparator, initialSize,
         pageSizeBytes, numElementsForSpillThreshold, inMemorySorter, false /* 
ignored */);
     sorter.spill(Long.MAX_VALUE, sorter);
+    taskContext.taskMetrics().incMemoryBytesSpilled(existingMemoryConsumption);

Review comment:
       At the end of `sorter.spill`,  it increase memory bytes spilled and disk 
bytes spilled. 
   But the size of memory bytes spilled is not correct because the real data 
pages are not `UnsafeExternalSorter.allocatedPages`, but 
`BytesToBytesMap.dataPages`,  as explained here 
https://github.com/apache/spark/pull/28780#discussion_r443445290, but the disk 
bytes spilled is correct because it's the real size write to disk.




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

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to