Skip to content

Commit 1fc85c3

Browse files
committed
Merge branch 'feature/#204/improve-parser-for-openjdk11' into develop
2 parents 6a76d89 + 51801bd commit 1fc85c3

File tree

3 files changed

+141
-1
lines changed

3 files changed

+141
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,7 @@ public String toString() {
660660
public static final Type UJL_CMS_CONCURRENT_OLD = new Type("Old", Generation.TENURED, Concurrency.CONCURRENT, GcPattern.GC_MEMORY);
661661

662662
// unified jvm logging g1 event types
663+
public static final Type UJL_G1_PAUSE_YOUNG = new Type("Pause Young (G1 Evacuation Pause)", Generation.YOUNG, Concurrency.SERIAL, GcPattern.GC_MEMORY_PAUSE);
663664
public static final Type UJL_G1_PAUSE_MIXED = new Type("Pause Mixed", Generation.TENURED, Concurrency.SERIAL, GcPattern.GC_MEMORY_PAUSE);
664665
public static final Type UJL_G1_TO_SPACE_EXHAUSTED = new Type("To-space exhausted", Generation.YOUNG, Concurrency.SERIAL, GcPattern.GC);
665666
public static final Type UJL_G1_CONCURRENT_CYCLE = new Type("Concurrent Cycle", Generation.TENURED, Concurrency.CONCURRENT, GcPattern.GC_PAUSE);
@@ -673,6 +674,8 @@ public String toString() {
673674
public static final Type UJL_G1_PHASE_EVACUATE_COLLECTION_SET = new Type("Evacuate Collection Set", Generation.YOUNG, Concurrency.SERIAL, GcPattern.GC_PAUSE);
674675
public static final Type UJL_G1_PHASE_POST_EVACUATE_COLLECTION_SET = new Type("Post Evacuate Collection Set", Generation.YOUNG, Concurrency.SERIAL, GcPattern.GC_PAUSE);
675676
public static final Type UJL_G1_PHASE_OTHER = new Type("Other", Generation.YOUNG, Concurrency.SERIAL, GcPattern.GC_PAUSE);
677+
public static final Type UJL_G1_PHASE_PREPARE_FOR_COMPACTION = new Type("Phase 2: Prepare for compaction", Generation.YOUNG, Concurrency.SERIAL, GcPattern.GC_PAUSE);
678+
public static final Type UJL_G1_PHASE_COMPACT_HEAP = new Type("Phase 4: Compact heap", Generation.YOUNG, Concurrency.SERIAL, GcPattern.GC_PAUSE);
676679

677680
// unified jvm logging shenandoah event types
678681
public static final Type UJL_SHEN_INIT_MARK = new Type("Pause Init Mark", Generation.TENURED, Concurrency.SERIAL, GcPattern.GC_PAUSE);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public void testParseGcWithPhases() throws Exception {
221221

222222
assertThat("number of warnings", handler.getCount(), is(0));
223223
assertThat("number of events", model.size(), is(1));
224-
assertThat("event type", model.get(0).getExtendedType().getType(), is(Type.UJL_PAUSE_YOUNG));
224+
assertThat("event type", model.get(0).getExtendedType().getType(), is(Type.UJL_G1_PAUSE_YOUNG));
225225
assertThat("event pause", model.get(0).getPause(), closeTo(0.007033, 0.0000001));
226226

227227
assertThat("phases", model.getGcEventPhases().size(), is(4));
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
package com.tagtraum.perf.gcviewer.imp;
2+
3+
import static org.hamcrest.Matchers.closeTo;
4+
import static org.hamcrest.Matchers.is;
5+
import static org.junit.Assert.assertThat;
6+
7+
import java.io.ByteArrayInputStream;
8+
import java.io.IOException;
9+
import java.io.InputStream;
10+
import java.util.logging.Level;
11+
12+
import com.tagtraum.perf.gcviewer.UnittestHelper;
13+
import com.tagtraum.perf.gcviewer.UnittestHelper.FOLDER;
14+
import com.tagtraum.perf.gcviewer.model.GCModel;
15+
import com.tagtraum.perf.gcviewer.model.GCResource;
16+
import com.tagtraum.perf.gcviewer.model.GcResourceFile;
17+
import org.junit.Test;
18+
19+
/**
20+
* Test unified java logging G1 algorithm in OpenJDK 11
21+
*/
22+
public class TestDataReaderUJLG1JDK11 {
23+
private GCModel getGCModelFromLogFile(String fileName) throws IOException {
24+
return UnittestHelper.getGCModelFromLogFile(fileName, FOLDER.OPENJDK_UJL, DataReaderUnifiedJvmLogging.class);
25+
}
26+
27+
@Test
28+
public void testDefaultsPauseYoungNormal() throws Exception {
29+
TestLogHandler handler = new TestLogHandler();
30+
handler.setLevel(Level.WARNING);
31+
GCResource gcResource = new GcResourceFile("byteArray");
32+
gcResource.getLogger().addHandler(handler);
33+
InputStream in = new ByteArrayInputStream(
34+
("[1.113s][info][gc] GC(4) Pause Young (Normal) (G1 Evacuation Pause) 70M->70M(128M) 12.615ms")
35+
.getBytes());
36+
37+
DataReader reader = new DataReaderUnifiedJvmLogging(gcResource, in);
38+
GCModel model = reader.read();
39+
40+
assertThat("number of warnings", handler.getCount(), is(0));
41+
assertThat("number of events", model.size(), is(1));
42+
assertThat("pause", model.get(0).getPause(), closeTo(0.012615, 0.00000001));
43+
}
44+
45+
@Test
46+
public void testDefaultsPauseYoungConcurrentStart() throws Exception {
47+
TestLogHandler handler = new TestLogHandler();
48+
handler.setLevel(Level.WARNING);
49+
GCResource gcResource = new GcResourceFile("byteArray");
50+
gcResource.getLogger().addHandler(handler);
51+
InputStream in = new ByteArrayInputStream(
52+
("[1.155s][info][gc] GC(5) Pause Young (Concurrent Start) (G1 Evacuation Pause) 84M->79M(128M) 5.960ms")
53+
.getBytes());
54+
55+
DataReader reader = new DataReaderUnifiedJvmLogging(gcResource, in);
56+
GCModel model = reader.read();
57+
58+
assertThat("number of warnings", handler.getCount(), is(0));
59+
assertThat("number of events", model.size(), is(1));
60+
assertThat("heap before", model.get(0).getPreUsed(), is(84 * 1024));
61+
}
62+
63+
@Test
64+
public void testDefaultsPauseYoungPrepareMixed() throws Exception {
65+
TestLogHandler handler = new TestLogHandler();
66+
handler.setLevel(Level.WARNING);
67+
GCResource gcResource = new GcResourceFile("byteArray");
68+
gcResource.getLogger().addHandler(handler);
69+
InputStream in = new ByteArrayInputStream(
70+
("[2.649s][info][gc] GC(218) Pause Young (Prepare Mixed) (G1 Evacuation Pause) 81M->79M(128M) 1.322ms")
71+
.getBytes());
72+
73+
DataReader reader = new DataReaderUnifiedJvmLogging(gcResource, in);
74+
GCModel model = reader.read();
75+
76+
assertThat("number of warnings", handler.getCount(), is(0));
77+
assertThat("number of events", model.size(), is(1));
78+
assertThat("heap after", model.get(0).getPostUsed(), is(79 * 1024));
79+
}
80+
81+
@Test
82+
public void testDefaultsPauseYoungMixed() throws Exception {
83+
TestLogHandler handler = new TestLogHandler();
84+
handler.setLevel(Level.WARNING);
85+
GCResource gcResource = new GcResourceFile("byteArray");
86+
gcResource.getLogger().addHandler(handler);
87+
InputStream in = new ByteArrayInputStream(
88+
("[2.651s][info][gc] GC(219) Pause Young (Mixed) (G1 Evacuation Pause) 84M->83M(128M) 1.599ms")
89+
.getBytes());
90+
91+
DataReader reader = new DataReaderUnifiedJvmLogging(gcResource, in);
92+
GCModel model = reader.read();
93+
94+
assertThat("number of warnings", handler.getCount(), is(0));
95+
assertThat("number of events", model.size(), is(1));
96+
assertThat("total heap", model.get(0).getTotal(), is(128 * 1024));
97+
}
98+
99+
@Test
100+
public void testFullGcWithPhases() throws Exception {
101+
TestLogHandler handler = new TestLogHandler();
102+
handler.setLevel(Level.WARNING);
103+
GCResource gcResource = new GcResourceFile("byteArray");
104+
gcResource.getLogger().addHandler(handler);
105+
InputStream in = new ByteArrayInputStream(
106+
("[1.204s][info][gc,task ] GC(15) Using 3 workers of 4 for full compaction\n" +
107+
"[1.204s][info][gc,start ] GC(15) Pause Full (G1 Evacuation Pause)\n" +
108+
"[1.204s][info][gc,phases,start] GC(15) Phase 1: Mark live objects\n" +
109+
"[1.207s][info][gc,stringtable ] GC(15) Cleaned string and symbol table, strings: 7381 processed, 70 removed, symbols: 49128 processed, 10 removed\n" +
110+
"[1.207s][info][gc,phases ] GC(15) Phase 1: Mark live objects 3.036ms\n" +
111+
"[1.207s][info][gc,phases,start] GC(15) Phase 2: Prepare for compaction\n" +
112+
"[1.208s][info][gc,phases ] GC(15) Phase 2: Prepare for compaction 0.808ms\n" +
113+
"[1.208s][info][gc,phases,start] GC(15) Phase 3: Adjust pointers\n" +
114+
"[1.210s][info][gc,phases ] GC(15) Phase 3: Adjust pointers 1.916ms\n" +
115+
"[1.210s][info][gc,phases,start] GC(15) Phase 4: Compact heap\n" +
116+
"[1.223s][info][gc,phases ] GC(15) Phase 4: Compact heap 13.268ms\n" +
117+
"[1.224s][info][gc,heap ] GC(15) Eden regions: 0->0(17)\n" +
118+
"[1.224s][info][gc,heap ] GC(15) Survivor regions: 0->0(1)\n" +
119+
"[1.224s][info][gc,heap ] GC(15) Old regions: 128->62\n" +
120+
"[1.224s][info][gc,heap ] GC(15) Humongous regions: 0->0\n" +
121+
"[1.224s][info][gc,metaspace ] GC(15) Metaspace: 15025K->15025K(1062912K)\n" +
122+
"[1.224s][info][gc ] GC(15) Pause Full (G1 Evacuation Pause) 127M->59M(128M) 20.596ms\n" +
123+
"[1.225s][info][gc,cpu ] GC(15) User=0.05s Sys=0.00s Real=0.02s\n" +
124+
"[1.225s][info][safepoint ] Leaving safepoint region\n" +
125+
"[1.225s][info][safepoint ] Total time for which application threads were stopped: 0.0222150 seconds, Stopping threads took: 0.0000452 seconds\n")
126+
.getBytes());
127+
128+
DataReader reader = new DataReaderUnifiedJvmLogging(gcResource, in);
129+
GCModel model = reader.read();
130+
131+
assertThat("number of warnings", handler.getCount(), is(0));
132+
assertThat("number of events", model.size(), is(1));
133+
assertThat("total heap", model.get(0).getTotal(), is(128 * 1024));
134+
135+
}
136+
137+
}

0 commit comments

Comments
 (0)