Skip to content
Prev Previous commit
Next Next commit
address the comments
  • Loading branch information
LantaoJin committed Feb 21, 2019
commit ba500fe816954ff9e82b4cb92215d8eaecc1dd4f
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ case object ProcessTreeMetrics extends ExecutorMetricType {
}

case object GarbageCollectionMetrics extends ExecutorMetricType with Logging {
private var nonBuiltInCollectors: Seq[String] = Nil

override val names = Seq(
"MinorGCCount",
"MinorGCTime",
Expand Down Expand Up @@ -135,17 +137,21 @@ case object GarbageCollectionMetrics extends ExecutorMetricType with Logging {

override private[spark] def getMetricValues(memoryManager: MemoryManager): Array[Long] = {
val gcMetrics = new Array[Long](names.length) // minorCount, minorTime, majorCount, majorTime
ManagementFactory.getGarbageCollectorMXBeans.asScala.foreach { mxBean =>
ManagementFactory.getGarbageCollectorMXBeans.asScala.foreach { mxBean =>
if (youngGenerationGarbageCollector.contains(mxBean.getName)) {
gcMetrics(0) = mxBean.getCollectionCount
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it ever possible that multiple collectors are considered young generation (or old generation)? If so, you'd want to use += here.

I'm not sure if there is a configuration where that might happen, but I'm also not super familiar with all variants here. @kiszk maybe you know?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, one collector per generation is supported only.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for being late. I agree with one collector per generation.

gcMetrics(1) = mxBean.getCollectionTime
} else if (oldGenerationGarbageCollector.contains(mxBean.getName)) {
gcMetrics(2) = mxBean.getCollectionCount
gcMetrics(3) = mxBean.getCollectionTime
} else {
logDebug(s"${mxBean.getName} is an unsupported garbage collector." +
s"Add it to ${config.EVENT_LOG_GC_METRICS_YOUNG_GENERATION_GARBAGE_COLLECTORS.key} " +
} else if (!nonBuiltInCollectors.contains(mxBean.getName)) {
nonBuiltInCollectors = mxBean.getName +: nonBuiltInCollectors
// log it when first seen
logWarning(s"Add the non-built-in garbage collector(s) $nonBuiltInCollectors " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: to me, the subject of this sentence is unclear. At first, I interpreted as (Spark) add the ..... Can we make it clear?
For example, Please add ... or Users should add ....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kiszk Yes, I've modified it now.

s"to ${config.EVENT_LOG_GC_METRICS_YOUNG_GENERATION_GARBAGE_COLLECTORS.key} " +
s"or ${config.EVENT_LOG_GC_METRICS_OLD_GENERATION_GARBAGE_COLLECTORS.key} to enable.")
} else {
// do nothing
}
}
gcMetrics
Expand Down