Skip to content

Commit 272ff74

Browse files
HADOOP-19461. JVM GC Metrics supports Generational ZGC pause time
1 parent 22b8fcd commit 272ff74

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/source/JvmMetrics.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,21 @@ private void getGcUsage(MetricsRecordBuilder rb) {
181181
long count = 0;
182182
long timeMillis = 0;
183183
for (GarbageCollectorMXBean gcBean : gcBeans) {
184-
if (gcBean.getName() != null) {
185-
String name = gcBean.getName();
184+
String gcBeanName = gcBean.getName();
185+
if (gcBeanName == null || gcBeanName.startsWith("ZGC") && gcBeanName.endsWith("Cycles")) {
186186
// JDK-8265136 Skip concurrent phase
187-
if (name.startsWith("ZGC") && name.endsWith("Cycles")) {
188-
continue;
189-
}
187+
continue;
190188
}
191189
long c = gcBean.getCollectionCount();
192190
long t = gcBean.getCollectionTime();
193-
MetricsInfo[] gcInfo = getGcInfo(gcBean.getName());
191+
if (gcBeanName.startsWith("ZGC")) {
192+
if (gcBeanName.contains("Minor")) {
193+
rb.addCounter(MinorGcCount, c).addCounter(MinorGcTimeMillis, t);
194+
} else {
195+
rb.addCounter(MajorGcCount, c).addCounter(MajorGcTimeMillis, t);
196+
}
197+
}
198+
MetricsInfo[] gcInfo = getGcInfo(gcBeanName);
194199
rb.addCounter(gcInfo[0], c).addCounter(gcInfo[1], t);
195200
count += c;
196201
timeMillis += t;

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/source/JvmMetricsInfo.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ public enum JvmMetricsInfo implements MetricsInfo {
3939
MemMaxM("Max memory size in MB"),
4040
GcCount("Total GC count"),
4141
GcTimeMillis("Total GC time in milliseconds"),
42+
MinorGcCount("Minor GC Count"),
43+
MajorGcCount("Major GC Count"),
44+
MinorGcTimeMillis("Minor GC time in milliseconds"),
45+
MajorGcTimeMillis("Major GC time in milliseconds"),
4246
ThreadsNew("Number of new threads"),
4347
ThreadsRunnable("Number of runnable threads"),
4448
ThreadsBlocked("Number of blocked threads"),

0 commit comments

Comments
 (0)