squito commented on a change in pull request #22874: [SPARK-25865][CORE] Add GC 
information to ExecutorMetrics
URL: https://github.com/apache/spark/pull/22874#discussion_r243059438
 
 

 ##########
 File path: 
core/src/main/scala/org/apache/spark/metrics/ExecutorMetricType.scala
 ##########
 @@ -99,6 +100,61 @@ case object ProcessTreeMetrics extends ExecutorMetricType {
   }
 }
 
+case object GarbageCollectionMetrics extends ExecutorMetricType {
+  import GC_TYPE._
+  override val names = Seq(
+    "MinorGCCount",
+    "MinorGCTime",
+    "MajorGCCount",
+    "MajorGCTime"
+  )
+  override private[spark] def getMetricValues(memoryManager: MemoryManager): 
Array[Long] = {
+    var allMetrics = GCMetrics(0, 0, 0, 0)
+    ManagementFactory.getGarbageCollectorMXBeans.asScala.foreach { mxBean =>
+      val metrics = mxBean.getName match {
+        case `copy` | `psScavenge` | `parNew` | `g1Young` =>
+          GCMetrics(mxBean.getCollectionCount, mxBean.getCollectionTime, 0, 0)
+        case `markSweepCompact` | `psMarkSweep` | `cms` | `g1Old` =>
+          GCMetrics(0, 0, mxBean.getCollectionCount, mxBean.getCollectionTime)
+        case _ =>
+          GCMetrics(0, 0, 0, 0)
+      }
+      allMetrics += metrics
+    }
+    val gcMetricsAsSet = new Array[Long](names.size)
 
 Review comment:
   I'd remove the `asSet` part of the name here -- not really a Set, order 
matters

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