Github user JoshRosen commented on a diff in the pull request:
https://github.com/apache/spark/pull/10634#discussion_r49656738
--- Diff:
sql/core/src/main/java/org/apache/spark/sql/execution/UnsafeKVExternalSorter.java
---
@@ -125,7 +125,8 @@ public UnsafeKVExternalSorter(
// reset the map, so we can re-use it to insert new records. the
inMemSorter will not used
// anymore, so the underline array could be used by map again.
- map.reset();
+ final long spillSize = map.reset();
+ taskContext.taskMetrics().incMemoryBytesSpilled(spillSize);
--- End diff --
According to my understanding of spill metrics, a spill needs to update
both `memoryBytesSpilled` and `diskBytesSpilled`. The memory spill is the
in-memory size of the data being spilled, while the disk spill records the size
of that data after it has been serialized and written to disk. As a result, I
think that there must be a corresponding `incDiskBytesSpilled` call somewhere.
I'm thinking that this memory spill metric should be updated closer to the site
of where we increment the disk bytes spilled rather than here, since I think
doing it that way would make it easier to reason about whether we're
double-counting.
If this does turn out to be the right place for this spill, it would be
great to add a code comment explaining the rationale for why this call must be
here.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]