Skip to content

Commit

Permalink
Initial unified G1 details parsing + bug fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmillson committed Dec 13, 2018
1 parent 8887462 commit 2662651
Show file tree
Hide file tree
Showing 39 changed files with 2,576 additions and 282 deletions.
5 changes: 3 additions & 2 deletions src/main/java/org/eclipselabs/garbagecat/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,9 @@ public static void createReport(JvmRun jvmRun, String reportFileName, boolean ve
}
}
bufferedWriter.write(Constants.LINE_SEPARATOR);
// Inverted parallelism. Only report if we have Serial/Parallel/CMS/G1 events.
if (jvmRun.getCollectorFamilies() != null && jvmRun.getCollectorFamilies().size() > 0) {
// Inverted parallelism. Only report if we have Serial/Parallel/CMS/G1 events with times data.
if (jvmRun.getCollectorFamilies() != null && jvmRun.getCollectorFamilies().size() > 0
&& jvmRun.getParallelCount() > 0) {
bufferedWriter.write("# Parallel Events: " + jvmRun.getParallelCount() + Constants.LINE_SEPARATOR);
bufferedWriter.write("# Inverted Parallelism: " + jvmRun.getInvertedParallelismCount()
+ Constants.LINE_SEPARATOR);
Expand Down
25 changes: 24 additions & 1 deletion src/main/java/org/eclipselabs/garbagecat/domain/TimesData.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,21 @@
* <h3>Example Logging</h3>
*
* <p>
* JDK8 and prior:
* </p>
*
* <pre>
* [Times: user=0.31 sys=0.00, real=0.04 secs]
* </pre>
*
* <p>
* JDK9+:
* </p>
*
* <pre>
* User=0.00s Sys=0.00s Real=0.00s
* </pre>
*
* @author <a href="mailto:mmillson@redhat.com">Mike Millson</a>
*
*/
Expand All @@ -29,9 +41,20 @@ public interface TimesData {
/**
* Regular expression for times data block.
*/
String REGEX = "( \\[Times: user=(\\d{1,5}[\\.\\,]\\d{2}) sys=\\d{1,5}[\\.\\,]\\d{2}, "
public static final String REGEX = "( \\[Times: user=(\\d{1,5}[\\.\\,]\\d{2}) sys=\\d{1,5}[\\.\\,]\\d{2}, "
+ "real=(\\d{1,5}[\\.\\,]\\d{2}) secs\\])";

/**
* Regular expression for times data block JDK9+.
*/
public static final String REGEX_JDK9 = "( User=(\\d{1,5}[\\.\\,]\\d{2})s Sys=\\d{1,5}[\\.\\,]\\d{2}s "
+ "Real=(\\d{1,5}[\\.\\,]\\d{2})s)";

/**
* Use for logging events that do not include times data.
*/
public static final int NO_DATA = -Integer.MIN_VALUE;

/**
* @return The time of all threads added together in centiseconds.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,4 @@ public long getTimestamp() {
public static final boolean match(String logLine) {
return pattern.matcher(logLine).matches();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/**********************************************************************************************************************
* garbagecat *
* *
* Copyright (c) 2008-2016 Red Hat, Inc. *
* *
* All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse *
* Public License v1.0 which accompanies this distribution, and is available at *
* http://www.eclipse.org/legal/epl-v10.html. *
* *
* Contributors: *
* Red Hat, Inc. - initial API and implementation *
*********************************************************************************************************************/
package org.eclipselabs.garbagecat.domain.jdk.unified;

import org.eclipselabs.garbagecat.domain.LogEvent;
import org.eclipselabs.garbagecat.domain.ThrowAwayEvent;
import org.eclipselabs.garbagecat.util.jdk.JdkRegEx;
import org.eclipselabs.garbagecat.util.jdk.JdkUtil;

/**
* <p>
* FOOTER_HEAP
* </p>
*
* <p>
* Heap information printed at the end of gc logging with unified detailed logging
* (<code>-Xlog:gc*:file=&lt;file&gt;</code>).
* </p>
*
* <h3>Example Logging</h3>
*
* <pre>
* [25.016s][info][gc,heap,exit ] Heap
* [25.016s][info][gc,heap,exit ] garbage-first heap total 59392K, used 38015K [0x00000000fc000000, 0x0000000100000000)
* [25.016s][info][gc,heap,exit ] region size 1024K, 13 young (13312K), 1 survivors (1024K)
* [25.016s][info][gc,heap,exit ] Metaspace used 11079K, capacity 11287K, committed 11520K, reserved 1060864K
* [25.016s][info][gc,heap,exit ] class space used 909K, capacity 995K, committed 1024K, reserved 1048576K
* </pre>
*
* @author <a href="mailto:mmillson@redhat.com">Mike Millson</a>
*
*/
public class FooterHeapEvent implements UnifiedLogging, LogEvent, ThrowAwayEvent {

/**
* Regular expression for heap line.
*/
private static final String REGEX_HEAP = "^\\[" + JdkRegEx.TIMESTAMP + "s\\]\\[info\\]\\[gc,heap,exit \\] Heap$";

/**
* Regular expression for garbage-first line.
*/
private static final String REGEX_GARBAGE_FIRST = "^\\[" + JdkRegEx.TIMESTAMP
+ "s\\]\\[info\\]\\[gc,heap,exit \\] garbage-first heap total " + JdkRegEx.SIZE + ", used "
+ JdkRegEx.SIZE + " \\[" + JdkRegEx.ADDRESS + ", " + JdkRegEx.ADDRESS + "\\)$";

/**
* Regular expression for region line.
*/
private static final String REGEX_REGION = "^\\[" + JdkRegEx.TIMESTAMP
+ "s\\]\\[info\\]\\[gc,heap,exit \\] region size " + JdkRegEx.SIZE + ", \\d{1,2} young \\("
+ JdkRegEx.SIZE + "\\), \\d{1} survivors \\(" + JdkRegEx.SIZE + "\\)$";

/**
* Regular expression for metaspace line.
*/
private static final String REGEX_METASPACE = "^\\[" + JdkRegEx.TIMESTAMP
+ "s\\]\\[info\\]\\[gc,heap,exit \\] Metaspace used " + JdkRegEx.SIZE + ", capacity "
+ JdkRegEx.SIZE + ", committed " + JdkRegEx.SIZE + ", reserved " + JdkRegEx.SIZE + "$";

/**
* Regular expression for class line.
*/
private static final String REGEX_CLASS = "^\\[" + JdkRegEx.TIMESTAMP
+ "s\\]\\[info\\]\\[gc,heap,exit \\] class space used " + JdkRegEx.SIZE + ", capacity "
+ JdkRegEx.SIZE + ", committed " + JdkRegEx.SIZE + ", reserved " + JdkRegEx.SIZE + "$";

/**
* The log entry for the event. Can be used for debugging purposes.
*/
private String logEntry;

/**
* The time when the GC event started in milliseconds after JVM startup.
*/
private long timestamp;

/**
* Create event from log entry.
*
* @param logEntry
* The log entry for the event.
*/
public FooterHeapEvent(String logEntry) {
this.logEntry = logEntry;
this.timestamp = 0L;
}

public String getLogEntry() {
return logEntry;
}

public String getName() {
return JdkUtil.LogEventType.FOOTER_HEAP.toString();
}

public long getTimestamp() {
return timestamp;
}

/**
* Determine if the logLine matches the logging pattern(s) for this event.
*
* @param logLine
* The log line to test.
* @return true if the log line matches the event pattern, false otherwise.
*/
public static final boolean match(String logLine) {
return (logLine.matches(REGEX_HEAP) || logLine.matches(REGEX_GARBAGE_FIRST) || logLine.matches(REGEX_REGION)
|| logLine.matches(REGEX_METASPACE) || logLine.matches(REGEX_CLASS));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**********************************************************************************************************************
* garbagecat *
* *
* Copyright (c) 2008-2016 Red Hat, Inc. *
* *
* All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse *
* Public License v1.0 which accompanies this distribution, and is available at *
* http://www.eclipse.org/legal/epl-v10.html. *
* *
* Contributors: *
* Red Hat, Inc. - initial API and implementation *
*********************************************************************************************************************/
package org.eclipselabs.garbagecat.domain.jdk.unified;

import java.util.regex.Pattern;

import org.eclipselabs.garbagecat.domain.LogEvent;
import org.eclipselabs.garbagecat.domain.ThrowAwayEvent;
import org.eclipselabs.garbagecat.util.jdk.JdkRegEx;
import org.eclipselabs.garbagecat.util.jdk.JdkUtil;

/**
* <p>
* HEAP_ADDRESS
* </p>
*
* <p>
* Heap address information printed at the beginning gc logging with unified detailed logging
* (<code>-Xlog:gc*:file=&lt;file&gt;</code>).
* </p>
*
* <h3>Example Logging</h3>
*
* <pre>
* [0.004s][info][gc,heap,coops] Heap address: 0x00000000fc000000, size: 64 MB, Compressed Oops mode: 32-bit
* </pre>
*
* @author <a href="mailto:mmillson@redhat.com">Mike Millson</a>
*
*/
public class HeapAddressEvent implements UnifiedLogging, LogEvent, ThrowAwayEvent {

/**
* Regular expressions defining the logging.
*/
private static final String REGEX = "^\\[" + JdkRegEx.TIMESTAMP + "s\\]\\[info\\]\\[gc,heap,coops\\] Heap address: "
+ JdkRegEx.ADDRESS + ", size: \\d{1,8} MB, Compressed Oops mode: 32-bit$";

private static final Pattern pattern = Pattern.compile(REGEX);

/**
* The log entry for the event. Can be used for debugging purposes.
*/
private String logEntry;

/**
* The time when the GC event started in milliseconds after JVM startup.
*/
private long timestamp;

/**
* Create event from log entry.
*
* @param logEntry
* The log entry for the event.
*/
public HeapAddressEvent(String logEntry) {
this.logEntry = logEntry;
this.timestamp = 0L;
}

public String getLogEntry() {
return logEntry;
}

public String getName() {
return JdkUtil.LogEventType.HEAP_ADDRESS.toString();
}

public long getTimestamp() {
return timestamp;
}

/**
* Determine if the logLine matches the logging pattern(s) for this event.
*
* @param logLine
* The log line to test.
* @return true if the log line matches the event pattern, false otherwise.
*/
public static final boolean match(String logLine) {
return pattern.matcher(logLine).matches();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**********************************************************************************************************************
* garbagecat *
* *
* Copyright (c) 2008-2016 Red Hat, Inc. *
* *
* All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse *
* Public License v1.0 which accompanies this distribution, and is available at *
* http://www.eclipse.org/legal/epl-v10.html. *
* *
* Contributors: *
* Red Hat, Inc. - initial API and implementation *
*********************************************************************************************************************/
package org.eclipselabs.garbagecat.domain.jdk.unified;

import java.util.regex.Pattern;

import org.eclipselabs.garbagecat.domain.LogEvent;
import org.eclipselabs.garbagecat.domain.ThrowAwayEvent;
import org.eclipselabs.garbagecat.util.jdk.JdkRegEx;
import org.eclipselabs.garbagecat.util.jdk.JdkUtil;

/**
* <p>
* HEAP_REGION_SIZE
* </p>
*
* <p>
* Heap region size information printed at the beginning gc logging with unified detailed logging
* (<code>-Xlog:gc*:file=&lt;file&gt;</code>).
* </p>
*
* <h3>Example Logging</h3>
*
* <pre>
* [0.003s][info][gc,heap] Heap region size: 1M
* </pre>
*
* @author <a href="mailto:mmillson@redhat.com">Mike Millson</a>
*
*/
public class HeapRegionSizeEvent implements UnifiedLogging, LogEvent, ThrowAwayEvent {

/**
* Regular expressions defining the logging.
*/
private static final String REGEX = "^\\[" + JdkRegEx.TIMESTAMP + "s\\]\\[info\\]\\[gc,heap\\] Heap region size: "
+ JdkRegEx.SIZE + "$";

private static final Pattern pattern = Pattern.compile(REGEX);

/**
* The log entry for the event. Can be used for debugging purposes.
*/
private String logEntry;

/**
* The time when the GC event started in milliseconds after JVM startup.
*/
private long timestamp;

/**
* Create event from log entry.
*
* @param logEntry
* The log entry for the event.
*/
public HeapRegionSizeEvent(String logEntry) {
this.logEntry = logEntry;
this.timestamp = 0L;
}

public String getLogEntry() {
return logEntry;
}

public String getName() {
return JdkUtil.LogEventType.HEAP_REGION_SIZE.toString();
}

public long getTimestamp() {
return timestamp;
}

/**
* Determine if the logLine matches the logging pattern(s) for this event.
*
* @param logLine
* The log line to test.
* @return true if the log line matches the event pattern, false otherwise.
*/
public static final boolean match(String logLine) {
return pattern.matcher(logLine).matches();
}
}
Loading

0 comments on commit 2662651

Please sign in to comment.