Skip to content

Commit de40b9d

Browse files
committed
More comments to try to explain metrics code
1 parent df07699 commit de40b9d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

core/src/main/java/org/apache/spark/shuffle/unsafe/UnsafeShuffleWriter.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,11 @@ private long[] mergeSpills(SpillInfo[] spills) throws IOException {
258258
logger.debug("Using slow merge");
259259
partitionLengths = mergeSpillsWithFileStream(spills, outputFile, compressionCodec);
260260
}
261-
// The final shuffle spill's write would have directly updated shuffleBytesWritten, so
262-
// we need to decrement to avoid double-counting this write.
261+
// When closing an UnsafeShuffleExternalSorter that has already spilled once but also has
262+
// in-memory records, we write out the in-memory records to a file but do not count that
263+
// final write as bytes spilled (instead, it's accounted as shuffle write). The merge needs
264+
// to be counted as shuffle write, but this will lead to double-counting of the final
265+
// SpillInfo's bytes.
263266
writeMetrics.decShuffleBytesWritten(spills[spills.length - 1].file.length());
264267
writeMetrics.incShuffleBytesWritten(outputFile.length());
265268
return partitionLengths;

0 commit comments

Comments
 (0)