squito commented on a change in pull request #23767: [SPARK-26329][CORE] Faster
polling of executor memory metrics.
URL: https://github.com/apache/spark/pull/23767#discussion_r268820822
##########
File path: core/src/main/scala/org/apache/spark/scheduler/TaskResult.scala
##########
@@ -68,6 +73,17 @@ private[spark] class DirectTaskResult[T](
}
accumUpdates = _accumUpdates
}
+
+ val numMetrics = in.readInt
+ if (numMetrics == 0) {
+ metricPeaks = Array.empty
+ } else {
+ val _metricPeaks = new ArrayBuffer[Long]
+ for (i <- 0 until numMetrics) {
+ _metricPeaks += in.readLong
+ }
+ metricPeaks = _metricPeaks.toArray
Review comment:
since you know the size you are reading, and you're going to create an array
in the end, you should just create the array in the first place.
```
val metricPeaks = new Array[Long](numMetrics)
(0 until numMetrics).foreach { idx =>
metricPeaks(idx) = in.readLong
}
```
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]