Skip to content

Commit eb89b1f

Browse files
authored
Merge pull request #231 from chewiebug/feature/#228/support-uptimemillis
Feature/#228/support uptimemillis
2 parents 695f8f4 + 1e4120d commit eb89b1f

File tree

6 files changed

+84
-4
lines changed

6 files changed

+84
-4
lines changed

pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@
7878
<name>Maciej Kwiecien</name>
7979
<url>https://github.com/xylu</url>
8080
</developer>
81+
<developer>
82+
<name>Dennis Lawler</name>
83+
<url>https://github.com/drawlerr</url>
84+
</developer>
8185
<developer>
8286
<name>Yanqi Li</name>
8387
<url>https://github.com/yanqilee</url>

src/main/java/com/tagtraum/perf/gcviewer/imp/DataReaderUnifiedJvmLogging.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ public class DataReaderUnifiedJvmLogging extends AbstractDataReader {
5959
// Regex: ^(?:\[(?<time>[0-9-T:.+]*)])?(?:\[(?<uptime>[^s]*)s])?\[(?<level>[^]]+)]\[(?:(?<tags>[^] ]+)[ ]*)][ ]GC\((?<gcnumber>[0-9]+)\)[ ](?<type>([-.a-zA-Z ()]+|[a-zA-Z1 ()]+))(?:(?:[ ](?<tail>[0-9]{1}.*))|$)
6060
// note for the <type> part: easiest would have been to use [^0-9]+, but the G1 events don't fit there, because of the number in their name
6161
private static final Pattern PATTERN_DECORATORS = Pattern.compile(
62-
"^(?:\\[(?<time>[0-9-T:.+]*)])?(?:\\[(?<uptime>[^s]*)s])?\\[(?<level>[^]]+)]\\[(?:(?<tags>[^] ]+)[ ]*)][ ]GC\\((?<gcnumber>[0-9]+)\\)[ ](?<type>(?:Phase [0-9]{1}: [a-zA-Z ]+)|[-.a-zA-Z: ()]+|[a-zA-Z1 ()]+)(?:(?:[ ](?<tail>[0-9]{1}.*))|$)"
62+
"^(?:\\[(?<time>[0-9-T:.+]*)])?(?:\\[(?<uptime>[^ms]*)(?<uptimeunit>m?s)])?\\[(?<level>[^]]+)]\\[(?:(?<tags>[^] ]+)[ ]*)][ ]GC\\((?<gcnumber>[0-9]+)\\)[ ](?<type>(?:Phase [0-9]{1}: [a-zA-Z ]+)|[-.a-zA-Z: ()]+|[a-zA-Z1 ()]+)(?:(?:[ ](?<tail>[0-9]{1}.*))|$)"
6363
);
6464
private static final String GROUP_DECORATORS_TIME = "time";
6565
private static final String GROUP_DECORATORS_UPTIME = "uptime";
66+
private static final String GROUP_DECORATORS_UPTIME_UNIT = "uptimeunit";
6667
private static final String GROUP_DECORATORS_LEVEL = "level";
6768
private static final String GROUP_DECORATORS_TAGS = "tags";
6869
private static final String GROUP_DECORATORS_GC_NUMBER = "gcnumber";
@@ -451,7 +452,7 @@ private AbstractGCEvent<?> createGcEventWithStandardDecorators(Matcher decorator
451452
event.setExtendedType(type);
452453
event.setNumber(Integer.parseInt(decoratorsMatcher.group(GROUP_DECORATORS_GC_NUMBER)));
453454
setDateStampIfPresent(event, decoratorsMatcher.group(GROUP_DECORATORS_TIME));
454-
setTimeStampIfPresent(event, decoratorsMatcher.group(GROUP_DECORATORS_UPTIME));
455+
setTimeStampIfPresent(event, decoratorsMatcher.group(GROUP_DECORATORS_UPTIME), decoratorsMatcher.group(GROUP_DECORATORS_UPTIME_UNIT));
455456
return event;
456457
} else {
457458
getLogger().warning(String.format("Failed to parse line number %d (no match; line=\"%s\")", in.getLineNumber(), line));
@@ -503,9 +504,13 @@ private void setDateStampIfPresent(AbstractGCEvent<?> event, String dateStampAsS
503504
}
504505
}
505506

506-
private void setTimeStampIfPresent(AbstractGCEvent<?> event, String timeStampAsString) {
507+
private void setTimeStampIfPresent(AbstractGCEvent<?> event, String timeStampAsString, String timeUnit) {
507508
if (timeStampAsString != null && timeStampAsString.length() > 0) {
508-
event.setTimestamp(NumberParser.parseDouble(timeStampAsString));
509+
double timestamp = NumberParser.parseDouble(timeStampAsString);
510+
if ("ms".equals(timeUnit)) {
511+
timestamp = timestamp / 1000;
512+
}
513+
event.setTimestamp(timestamp);
509514
}
510515
}
511516

src/main/java/com/tagtraum/perf/gcviewer/model/AbstractGCEvent.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@ public String toString() {
668668
public static final Type UJL_G1_SURVIVOR = new Type("Survivor regions", Generation.YOUNG, Concurrency.SERIAL, GcPattern.GC_REGION);
669669
public static final Type UJL_G1_OLD = new Type("Old regions", Generation.TENURED, Concurrency.SERIAL, GcPattern.GC_REGION);
670670
public static final Type UJL_G1_HUMongous = new Type("Humongous regions", Generation.TENURED, Concurrency.SERIAL, GcPattern.GC_REGION);
671+
public static final Type UJL_G1_ARCHIVE = new Type("Archive regions", Generation.TENURED, Concurrency.SERIAL, GcPattern.GC_REGION);
671672

672673
public static final Type UJL_G1_PHASE_PRE_EVACUATE_COLLECTION_SET = new Type("Pre Evacuate Collection Set", Generation.YOUNG, Concurrency.SERIAL, GcPattern.GC_PAUSE);
673674
public static final Type UJL_G1_PHASE_EVACUATE_COLLECTION_SET = new Type("Evacuate Collection Set", Generation.YOUNG, Concurrency.SERIAL, GcPattern.GC_PAUSE);

src/main/java/com/tagtraum/perf/gcviewer/view/AboutDialog.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public class AboutDialog extends ScreenCenteredDialog implements ActionListener
5252
"Mary Sunitha Joseph",
5353
"Johan Kaving",
5454
"Maciej Kwiecien",
55+
"Dennis Lawler",
5556
"Yanqi Li",
5657
"Henry Lin",
5758
"James Livingston",

src/test/java/com/tagtraum/perf/gcviewer/imp/TestDataReaderUJLG1JDK11.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,22 @@ public void testDefaultsPauseYoungNormal() throws Exception {
4343
assertThat("pause", model.get(0).getPause(), closeTo(0.012615, 0.00000001));
4444
}
4545

46+
@Test
47+
public void testNewUptimestamp() throws Exception {
48+
TestLogHandler handler = new TestLogHandler();
49+
handler.setLevel(Level.WARNING);
50+
GCResource gcResource = new GcResourceFile("byteArray");
51+
gcResource.getLogger().addHandler(handler);
52+
InputStream in = new ByteArrayInputStream(
53+
("[113ms][info][gc] GC(4) Pause Young (Normal) (G1 Evacuation Pause) 70M->70M(128M) 12.615ms")
54+
.getBytes());
55+
56+
DataReader reader = new DataReaderUnifiedJvmLogging(gcResource, in);
57+
GCModel model = reader.read();
58+
59+
assertThat(model.getEvents().next().getTimestamp(), is(0.113));
60+
}
61+
4662
@Test
4763
public void testDefaultsPauseYoungConcurrentStart() throws Exception {
4864
TestLogHandler handler = new TestLogHandler();
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.tagtraum.perf.gcviewer.imp;
2+
3+
import static org.hamcrest.Matchers.closeTo;
4+
import static org.hamcrest.Matchers.containsString;
5+
import static org.hamcrest.Matchers.is;
6+
import static org.junit.Assert.assertThat;
7+
8+
import java.io.ByteArrayInputStream;
9+
import java.io.InputStream;
10+
import java.util.logging.Level;
11+
12+
import com.tagtraum.perf.gcviewer.model.GCModel;
13+
import com.tagtraum.perf.gcviewer.model.GCResource;
14+
import com.tagtraum.perf.gcviewer.model.GcResourceFile;
15+
import org.junit.Test;
16+
17+
/**
18+
* Test unified java logging G1 algorithm in OpenJDK 12
19+
*/
20+
public class TestDataReaderUJLG1JDK12 {
21+
@Test
22+
public void testG1ArchiveRegions() throws Exception {
23+
TestLogHandler handler = new TestLogHandler();
24+
handler.setLevel(Level.WARNING);
25+
GCResource gcResource = new GcResourceFile("byteArray");
26+
gcResource.getLogger().addHandler(handler);
27+
InputStream in = new ByteArrayInputStream(
28+
("[2019-09-16T20:06:59.836+0000][0.153s][info][gc,start ] GC(0) Pause Young (Normal) (G1 Evacuation Pause)\n" +
29+
"[2019-09-16T20:06:59.836+0000][0.153s][info][gc,task ] GC(0) Using 2 workers of 2 for evacuation\n" +
30+
"[2019-09-16T20:06:59.840+0000][0.157s][info][gc,phases ] GC(0) Pre Evacuate Collection Set: 0.0ms\n" +
31+
"[2019-09-16T20:06:59.840+0000][0.157s][info][gc,phases ] GC(0) Evacuate Collection Set: 3.1ms\n" +
32+
"[2019-09-16T20:06:59.840+0000][0.157s][info][gc,phases ] GC(0) Post Evacuate Collection Set: 0.7ms\n" +
33+
"[2019-09-16T20:06:59.840+0000][0.157s][info][gc,phases ] GC(0) Other: 0.4ms\n" +
34+
"[2019-09-16T20:06:59.840+0000][0.157s][info][gc,heap ] GC(0) Eden regions: 7->0(4)\n" +
35+
"[2019-09-16T20:06:59.840+0000][0.157s][info][gc,heap ] GC(0) Survivor regions: 0->1(1)\n" +
36+
"[2019-09-16T20:06:59.840+0000][0.157s][info][gc,heap ] GC(0) Old regions: 0->6\n" +
37+
"[2019-09-16T20:06:59.840+0000][0.157s][info][gc,heap ] GC(0) Archive regions: 2->2\n" +
38+
"[2019-09-16T20:06:59.840+0000][0.157s][info][gc,heap ] GC(0) Humongous regions: 0->0\n" +
39+
"[2019-09-16T20:06:59.840+0000][0.157s][info][gc,metaspace ] GC(0) Metaspace: 189K->189K(1056768K)\n" +
40+
"[2019-09-16T20:06:59.840+0000][0.157s][info][gc ] GC(0) Pause Young (Normal) (G1 Evacuation Pause) 7M->7M(34M) 4.379ms\n" +
41+
"[2019-09-16T20:06:59.840+0000][0.157s][info][gc,cpu ] GC(0) User=0.00s Sys=0.01s Real=0.01s\n")
42+
.getBytes());
43+
44+
DataReader reader = new DataReaderUnifiedJvmLogging(gcResource, in);
45+
GCModel model = reader.read();
46+
47+
assertThat("number of warnings", handler.getCount(), is(0));
48+
assertThat("number of events", model.size(), is(1));
49+
assertThat("pause", model.get(0).getPause(), closeTo(0.004379, 0.0000001));
50+
assertThat("name", model.get(0).getTypeAsString(), containsString("Archive regions"));
51+
}
52+
53+
}

0 commit comments

Comments
 (0)