c21 commented on a change in pull request #31340:
URL: https://github.com/apache/spark/pull/31340#discussion_r566425077
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/ObjectAggregationIterator.scala
##########
@@ -76,6 +82,11 @@ class ObjectAggregationIterator(
*/
processInputs()
+ TaskContext.get().addTaskCompletionListener[Unit](_ => {
+ // At the end of the task, update the task's spill size.
+ spillSize.set(TaskContext.get().taskMetrics().memoryBytesSpilled -
spillSizeBefore)
Review comment:
@maropu - this is a good point. Given the [map value is a general
`InternalRow`](https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/ObjectAggregationMap.scala#L36),
I feel it's hard to get an accurate metrics for memory size of this map. Hive
aggregation uses a combination of [current JVM heap memory
usage](https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/exec/GroupByOperator.java#L872),
and [estimation of map
size](https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/exec/GroupByOperator.java#L919-L920)
to decide whether to spill. I think Hive's approach might be better. I am also
tagging queries in our production environment with object hash aggregate
fallback, and see how to improve them. Is it "memory-size-based object hash
aggregation fallback" a good topic to discuss? cc @maropu and @cloud-fan thanks.
----------------------------------------------------------------
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]