Github user yhuai commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9215#discussion_r42892965
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/metric/SQLMetrics.scala 
---
    @@ -62,7 +67,19 @@ private[sql] trait SQLMetricValue[T] extends 
Serializable {
     private[sql] class LongSQLMetricValue(private var _value : Long) extends 
SQLMetricValue[Long] {
     
       def add(incr: Long): LongSQLMetricValue = {
    -    _value += incr
    +    // Some LongSQLMetric will use -1 as initial value, so if the 
accumulator is never updated,
    +    // we can filter it out later.  However, when `add` is called, the 
accumulator is valid, we
    +    // should turn -1 to 0.
    +    if (_value < 0) {
    +      _value = 0
    +    }
    +
    +    // Some LongSQLMetric will use -1 as initial value, when we merge 
accumulator updates at driver
    +    // side, we should ignore these -1 values.
    +    if (incr > 0) {
    +      _value += incr
    +    }
    +
    --- End diff --
    
    @cloud-fan sorry. I just realized that this method is in the critical path 
(when we calculate numRows). How about we remove this change and document it 
clear that those negative initial values will have a small impact on the sum of 
memory consumption?


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