Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18301#discussion_r124709173
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/TungstenAggregationIterator.scala
 ---
    @@ -367,6 +367,22 @@ class TungstenAggregationIterator(
         }
       }
     
    +  TaskContext.get().addTaskCompletionListener(_ => {
    +    // At the end of the task, update the task's peak memory usage. Since 
we destroy
    +    // the map to create the sorter, their memory usages should not 
overlap, so it is safe
    +    // to just use the max of the two.
    +    val mapMemory = hashMap.getPeakMemoryUsedBytes
    +    val sorterMemory = 
Option(externalSorter).map(_.getPeakMemoryUsedBytes).getOrElse(0L)
    +    val maxMemory = Math.max(mapMemory, sorterMemory)
    +    val metrics = TaskContext.get().taskMetrics()
    +    peakMemory += maxMemory
    --- End diff --
    
    nit: it's more clear to call `set` here, instead of `+=`


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

Reply via email to