squito commented on a change in pull request #23767: [SPARK-26329][CORE][WIP] 
Faster polling of executor memory metrics.
URL: https://github.com/apache/spark/pull/23767#discussion_r258646579
 
 

 ##########
 File path: core/src/main/scala/org/apache/spark/executor/Executor.scala
 ##########
 @@ -840,8 +952,25 @@ private[spark] class Executor(
     val accumUpdates = new ArrayBuffer[(Long, Seq[AccumulatorV2[_, _]])]()
     val curGCTime = computeTotalGcTime()
 
-    // get executor level memory metrics
-    val executorUpdates = heartbeater.getCurrentMetrics()
+    // if not polling in a separater poller, poll here
+    if (poller == null) {
+      poll()
+    }
+
+    // build the executor level memory metrics
+    val executorUpdates = new HashMap[StageKey, ExecutorMetrics]
+
+    def peaksForStage(k: StageKey, v: AtomicLong): (StageKey, AtomicLongArray) 
=
+      if (v.get() > 0) (k, stageMetricPeaks.get(k)) else null
+
+    def addPeaks(nested: (StageKey, AtomicLongArray)): Unit = {
+      val (k, v) = nested
+      executorUpdates.put(k, new ExecutorMetrics(v))
+      // at the same time, reset the peaks in stageMetricPeaks
+      stageMetricPeaks.put(k, new 
AtomicLongArray(ExecutorMetricType.numMetrics))
+    }
+
+    activeStages.forEach[(StageKey, AtomicLongArray)](LONG_MAX_VALUE, 
peaksForStage, addPeaks)
 
 Review comment:
   there's two different cases to consider for the task failing: (a) the 
executor dies, in which case you wouldn't send back anything anyway later on 
anyway and (b) the task fails, but the executor is still fine (eg. an error in 
user code, or spark's internal memory manager decides there isn't enough memory 
so it fails more gracefully, etc.).  We could still send back metrics in that 
case and aggregate them.
   
   This change is currently not doing that, but it could: we'd need to make 
sure the metrics get added to the failure cases in `Executor`, and also add 
handling of metrics in `TaskSetManager.handleFailedTask`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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]

Reply via email to