ankuriitg commented on a change in pull request #23306: [SPARK-26357][Core] 
Expose executors' procfs metrics to Metrics system
URL: https://github.com/apache/spark/pull/23306#discussion_r243038405
 
 

 ##########
 File path: 
core/src/main/scala/org/apache/spark/executor/ProcfsMetricsGetter.scala
 ##########
 @@ -205,21 +210,44 @@ private[spark] class ProcfsMetricsGetter(procfsDir: 
String = "/proc/") extends L
     }
   }
 
+  private[spark] def isCacheValid(): Boolean = {
+    val lastMetricComputation = System.currentTimeMillis() - 
lastimeMetricsComputed
+    // ToDo: Should we make this configurable?
+    return  Math.min(1000, HEARTBEAT_INTERVAL_MS) > lastMetricComputation
+  }
+
   private[spark] def computeAllMetrics(): ProcfsMetrics = {
     if (!isAvailable) {
+      lastimeMetricsComputed = System.currentTimeMillis
+      cachedAllMetric = ProcfsMetrics(0, 0, 0, 0, 0, 0)
       return ProcfsMetrics(0, 0, 0, 0, 0, 0)
 
 Review comment:
   return cachedAllMetric
   Additionally, I see that we are creating a lot of instances for empty for 
ProcfsMetrics, maybe keep a static empty instance around and just return that 
if metrics are not available instead of creating a new instance everytime

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