Skip to content

Commit 114e0b1

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

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,24 @@ 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) {
186+
continue;
187+
}
188+
if (gcBeanName.startsWith("ZGC") && gcBeanName.endsWith("Cycles")) {
186189
// JDK-8265136 Skip concurrent phase
187-
if (name.startsWith("ZGC") && name.endsWith("Cycles")) {
188-
continue;
189-
}
190+
continue;
190191
}
191192
long c = gcBean.getCollectionCount();
192193
long t = gcBean.getCollectionTime();
193-
MetricsInfo[] gcInfo = getGcInfo(gcBean.getName());
194+
if (gcBeanName.startsWith("ZGC")) {
195+
if (gcBeanName.contains("Minor")) {
196+
rb.addCounter(MinorGcCount, c).addCounter(MinorGcTimeMillis, t);
197+
} else {
198+
rb.addCounter(MajorGcCount, c).addCounter(MajorGcTimeMillis, t);
199+
}
200+
}
201+
MetricsInfo[] gcInfo = getGcInfo(gcBeanName);
194202
rb.addCounter(gcInfo[0], c).addCounter(gcInfo[1], t);
195203
count += c;
196204
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)