Skip to content

Commit d74690e

Browse files
committed
enhance jdk8 parser for serial, cms and g1 printGCID events
1 parent fdb2490 commit d74690e

File tree

8 files changed

+244
-8
lines changed

8 files changed

+244
-8
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ protected DataReaderTools getDataReaderTools() {
6262
*/
6363
protected boolean shouldContinue() {
6464
if (getLogger().isLoggable(Level.FINE)) {
65-
getLogger().fine(gcResource.getResourceName() + " read cancelled");
65+
getLogger().fine(gcResource.getResourceName() + " read cancelled=" + gcResource.isReadCancelled());
6666
}
6767
return !gcResource.isReadCancelled();
6868
}

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

+5-6
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ protected String parseTypeString(String line, ParseInformation pos) throws Parse
256256
int i = pos.getIndex();
257257
try {
258258
// consume all leading spaces and [
259-
final int lineLength = line.length();
259+
final int lineLength = line.length() - 1;
260260
final char[] lineChars = line.toCharArray();
261261
char c = lineChars[i];
262262
for (; i<lineLength; c = lineChars[++i]) {
@@ -301,14 +301,13 @@ protected String parseTypeString(String line, ParseInformation pos) throws Parse
301301
}
302302
}
303303

304-
// restriction PringGCID only for parallel scavenge collector
305304
protected void parseGcId(String line, ParseInformation pos) throws ParseException {
306-
if (!line.contains("#"))
305+
if (!line.substring(pos.getIndex()).contains("#"))
307306
return;
308307
int i = pos.getIndex();
309308
try {
310309
// consume all leading spaces and '#'
311-
final int lineLength = line.length();
310+
final int lineLength = line.length() - 1;
312311
final char[] lineChars = line.toCharArray();
313312
char c = lineChars[i];
314313
for (; i < lineLength; c = lineChars[++i]) {
@@ -327,7 +326,6 @@ protected void parseGcId(String line, ParseInformation pos) throws ParseExceptio
327326
}
328327
}
329328
finally {
330-
i++;
331329
pos.setIndex(i);
332330
}
333331
}
@@ -542,6 +540,7 @@ protected void parseDetailEventsIfExist(final String line, final ParseInformatio
542540
detailEvent.setDateStamp(datestamp);
543541
detailEvent.setTimestamp(getTimestamp(line, pos, datestamp));
544542
}
543+
parseGcId(line, pos);
545544
detailEvent.setExtendedType(parseType(line, pos));
546545
if (nextIsTimestamp(line, pos) || nextIsDatestamp(line, pos)) {
547546
parseDetailEventsIfExist(line, pos, detailEvent);
@@ -686,7 +685,7 @@ else if (indexOfNextClosingBracket > 0) {
686685

687686
private int skipUntilNextDigit(String line, ParseInformation pos) throws ParseException {
688687
int begin = pos.getIndex();
689-
while (!Character.isDigit(line.charAt(begin)) && begin < line.length()) {
688+
while (!Character.isDigit(line.charAt(begin)) && begin+1 < line.length()) {
690689
++begin;
691690
}
692691

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

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
* <li>-XX:+PrintReferenceGC (output ignored)</li>
5959
* <li>-XX:+PrintCMSInitiationStatistics (output ignored)</li>
6060
* <li>-XX:+PrintFLSStatistics (output ignored)</li>
61+
* <li>-XX:+PrintGCID (output ignored)</li>
6162
* </ul>
6263
*
6364
* @author <a href="mailto:[email protected]">Hendrik Schreiber</a>

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
* <li>-XX:+PrintAdaptiveSizePolicy (output ignored)</li>
4949
* <li>-XX:+PrintReferenceGC (output ignored)</li>
5050
* <li>-XX:+PrintStringDeduplicationStatistics (output ignored)</li>
51+
* <li>-XX:+PrintGCID (output ignored)</li>
5152
* </ul>
5253
*
5354
* @author <a href="mailto:[email protected]">Joerg Wuethrich</a>
@@ -131,7 +132,7 @@ public class DataReaderSun1_6_0G1 extends AbstractDataReaderSun {
131132

132133
// the following pattern is specific for G1 with -XX:+PrintGCDetails
133134
// "[<datestamp>: ]0.295: [GC pause (young), 0.00594747 secs]"
134-
private static final Pattern PATTERN_GC_PAUSE = Pattern.compile("^([0-9-T:.+]{29})?[ ]?([0-9.,]+)?[: \\[]{2,3}([A-Z0-9a-z- ().]+)[, ]+([0-9.,]+)[ sec\\]]+$");
135+
private static final Pattern PATTERN_GC_PAUSE = Pattern.compile("^([0-9-T:.+]{29})?[ ]?([0-9.,]+)?(?:[ #0-9:]+)?[: \\[]{2,3}([A-Z0-9a-z- ().]+)[, ]+([0-9.,]+)[ sec\\]]+$");
135136
private static final int GC_PAUSE_GROUP_DATESTAMP = 1;
136137
private static final int GC_PAUSE_GROUP_TIMESTAMP = 2;
137138
private static final int GC_PAUSE_GROUP_TYPE = 3;

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

+44
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,30 @@ public void shenandoah_232_Beginning() throws Exception {
417417
is(1L));
418418
}
419419

420+
@Test
421+
public void serialPrintGCID() throws Exception {
422+
TestLogHandler handler = new TestLogHandler();
423+
handler.setLevel(Level.WARNING);
424+
GCResource gcResource = new GcResourceFile("byteArray");
425+
gcResource.getLogger().addHandler(handler);
426+
427+
ByteArrayInputStream in = new ByteArrayInputStream(
428+
("2022-08-01T17:14:32.660+0000: 0.177: #1: [GC (Allocation Failure) 2022-08-01T17:14:32.661+0000: 0.178: #1: [DefNew: 9766K->1056K(9792K), 0.0057621 secs] 16728K->16694K(31680K), 0.0073601 secs] [Times: user=0.00 sys=0.00, real=0.01 secs] \n" +
429+
"2022-08-01T17:14:32.671+0000: 0.188: #2: [GC (Allocation Failure) 2022-08-01T17:14:32.672+0000: 0.189: #2: [DefNew: 9746K->1056K(9792K), 0.0073505 secs]2022-08-01T17:14:32.680+0000: 0.197: #3: [Tenured: 24314K->24378K(24384K), 0.0036336 secs] 25384K->25370K(34176K), [Metaspace: 2712K->2712K(1056768K)], 0.0134215 secs] [Times: user=0.01 sys=0.00, real=0.02 secs] \n")
430+
.getBytes());
431+
432+
DataReader reader = new DataReaderSun1_6_0(gcResource, in, GcLogType.SUN1_8);
433+
GCModel model = reader.read();
434+
435+
assertThat("gc count", model.size(), is(2));
436+
assertThat("warnings", handler.getCount(), is(0));
437+
438+
AbstractGCEvent<?> secondEvent = model.get(1);
439+
assertThat("name", secondEvent.getTypeAsString(), equalTo("GC (Allocation Failure); DefNew; Tenured; Metaspace"));
440+
assertThat("duration", secondEvent.getPause(), closeTo(0.0134215, 0.0000001));
441+
assertThat("before", secondEvent.getPreUsed(), is(25384));
442+
}
443+
420444
@Test
421445
public void parallelPrintGCID() throws Exception {
422446
TestLogHandler handler = new TestLogHandler();
@@ -432,4 +456,24 @@ public void parallelPrintGCID() throws Exception {
432456
assertEquals("number of errors", 0, handler.getCount());
433457
}
434458

459+
@Test
460+
public void cmsPrintGCID() throws Exception {
461+
TestLogHandler handler = new TestLogHandler();
462+
handler.setLevel(Level.WARNING);
463+
GCResource gcResource = new GcResourceFile("SampleSun1_8_0CmsPrintGcId.txt");
464+
gcResource.getLogger().addHandler(handler);
465+
466+
DataReader reader = getDataReader(gcResource);
467+
GCModel model = reader.read();
468+
469+
assertThat("gc count", model.size(), is(18));
470+
assertThat("warnings", handler.getCount(), is(0));
471+
472+
AbstractGCEvent<?> parnew = model.get(0);
473+
assertThat("name", parnew.getTypeAsString(), equalTo("GC (Allocation Failure); ParNew"));
474+
assertThat("duration", parnew.getPause(), closeTo(0.0106548, 0.0000001));
475+
assertThat("before", parnew.getPreUsed(), is(8678));
476+
477+
}
478+
435479
}

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

+24
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static org.hamcrest.Matchers.closeTo;
44
import static org.hamcrest.Matchers.containsString;
5+
import static org.hamcrest.Matchers.equalTo;
56
import static org.hamcrest.Matchers.is;
67
import static org.junit.Assert.assertEquals;
78
import static org.junit.Assert.assertThat;
@@ -14,6 +15,7 @@
1415

1516
import com.tagtraum.perf.gcviewer.UnittestHelper;
1617
import com.tagtraum.perf.gcviewer.UnittestHelper.FOLDER;
18+
import com.tagtraum.perf.gcviewer.model.AbstractGCEvent;
1719
import com.tagtraum.perf.gcviewer.model.AbstractGCEvent.Type;
1820
import com.tagtraum.perf.gcviewer.model.GCEvent;
1921
import com.tagtraum.perf.gcviewer.model.GCModel;
@@ -212,4 +214,26 @@ public void ignorePrintStringDeduplicationStatistics() throws Exception {
212214
assertThat("size", model.size(), is(1));
213215
assertThat("type", model.get(0).getExtendedType().getType(), is(Type.G1_YOUNG));
214216
}
217+
218+
@Test
219+
public void printGCID() throws Exception {
220+
TestLogHandler handler = new TestLogHandler();
221+
handler.setLevel(Level.WARNING);
222+
GCResource gcResource = new GcResourceFile("SampleSun1_8_0G1PrintGCID.txt");
223+
gcResource.getLogger().addHandler(handler);
224+
225+
DataReader reader = getDataReader(gcResource);
226+
GCModel model = reader.read();
227+
228+
assertThat("warnings", handler.getCount(), is(0));
229+
assertThat("gc count", model.size(), is(11));
230+
231+
AbstractGCEvent<?> parnew = model.get(0);
232+
assertThat("name", parnew.getTypeAsString(), equalTo("GC pause (G1 Evacuation Pause) (young)"));
233+
assertThat("duration", parnew.getPause(), closeTo(0.0087570, 0.0000001));
234+
assertThat("before", parnew.getPreUsed(), is(7168));
235+
236+
}
237+
238+
215239
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
OpenJDK 64-Bit Server VM (25.342-b07) for linux-amd64 JRE (1.8.0_342-b07), built on Jul 16 2022 09:19:19 by "openjdk" with gcc 4.4.7 20120313 (Red Hat 4.4.7-23)
2+
Memory: 4k page, physical 2097152k(2094644k free), swap 3145728k(3145728k free)
3+
CommandLine flags: -XX:InitialHeapSize=33554432 -XX:MaxHeapSize=536870912 -XX:MaxNewSize=174485504 -XX:MaxTenuringThreshold=6 -XX:OldPLABSize=16 -XX:+PrintGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCID -XX:+PrintGCTimeStamps -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseConcMarkSweepGC -XX:+UseParNewGC
4+
2022-08-01T17:16:33.170+0000: 0.169: #0: [GC (Allocation Failure) 2022-08-01T17:16:33.171+0000: 0.170: #0: [ParNew: 8678K->1081K(9792K), 0.0088699 secs] 8678K->8064K(31680K), 0.0106548 secs] [Times: user=0.02 sys=0.00, real=0.01 secs]
5+
2022-08-01T17:16:33.185+0000: 0.185: #1: [GC (Allocation Failure) 2022-08-01T17:16:33.186+0000: 0.185: #1: [ParNew: 9760K->1056K(9792K), 0.0089566 secs] 16743K->16701K(31680K), 0.0103324 secs] [Times: user=0.02 sys=0.00, real=0.01 secs]
6+
2022-08-01T17:16:33.198+0000: 0.197: #2: [GC (CMS Initial Mark) [1 CMS-initial-mark: 15645K(21888K)] 18533K(31680K), 0.0010369 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
7+
2022-08-01T17:16:33.200+0000: 0.199: #2: [CMS-concurrent-mark-start]
8+
2022-08-01T17:16:33.201+0000: 0.201: #3: [GC (Allocation Failure) 2022-08-01T17:16:33.202+0000: 0.201: #3: [ParNew: 9746K->1056K(9792K), 0.0062763 secs] 25391K->25378K(34560K), 0.0073592 secs] [Times: user=0.01 sys=0.01, real=0.01 secs]
9+
2022-08-01T17:16:33.213+0000: 0.212: #2: [CMS-concurrent-mark: 0.005/0.013 secs] [Times: user=0.01 sys=0.01, real=0.02 secs]
10+
2022-08-01T17:16:33.214+0000: 0.213: #4: [GC (Allocation Failure) 2022-08-01T17:16:33.214+0000: 0.213: #4: [ParNew: 9751K->1056K(9792K), 0.0056495 secs] 34072K->34054K(43200K), 0.0064721 secs] [Times: user=0.01 sys=0.00, real=0.00 secs]
11+
2022-08-01T17:16:33.221+0000: 0.220: #2: [CMS-concurrent-preclean-start]
12+
2022-08-01T17:16:33.222+0000: 0.221: #2: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
13+
2022-08-01T17:16:33.222+0000: 0.222: #5: [GC (Allocation Failure) 2022-08-01T17:16:33.223+0000: 0.222: #5: [ParNew: 9754K->1056K(9792K), 0.0051785 secs] 42752K->42730K(51840K), 0.0060566 secs] [Times: user=0.01 sys=0.00, real=0.00 secs]
14+
2022-08-01T17:16:33.230+0000: 0.229: #2: [GC (CMS Final Remark) [YG occupancy: 1868 K (9792 K)]2022-08-01T17:16:33.230+0000: 0.230: #2: [Rescan (parallel) , 0.0007821 secs]2022-08-01T17:16:33.231+0000: 0.231: #2: [weak refs processing, 0.0004025 secs]2022-08-01T17:16:33.232+0000: 0.231: #2: [class unloading, 0.0005587 secs]2022-08-01T17:16:33.233+0000: 0.232: #2: [scrub symbol table, 0.0003980 secs]2022-08-01T17:16:33.233+0000: 0.233: #2: [scrub string table, 0.0002950 secs][1 CMS-remark: 41674K(42048K)] 43542K(51840K), 0.0039463 secs] [Times: user=0.01 sys=0.00, real=0.01 secs]
15+
2022-08-01T17:16:33.235+0000: 0.234: #2: [CMS-concurrent-sweep-start]
16+
2022-08-01T17:16:33.235+0000: 0.234: #2: [CMS-concurrent-sweep: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
17+
2022-08-01T17:16:33.235+0000: 0.235: #2: [CMS-concurrent-reset-start]
18+
2022-08-01T17:16:33.236+0000: 0.236: #6: [GC (Allocation Failure) 2022-08-01T17:16:33.237+0000: 0.236: #6: [ParNew: 9744K->1056K(9792K), 0.0026933 secs] 51417K->51405K(79248K), 0.0034839 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
19+
2022-08-01T17:16:33.244+0000: 0.243: #7: [GC (Allocation Failure) 2022-08-01T17:16:33.244+0000: 0.243: #7: [ParNew: 9745K->1056K(9792K), 0.0028328 secs] 60094K->60082K(79248K), 0.0037992 secs] [Times: user=0.00 sys=0.01, real=0.00 secs]
20+
2022-08-01T17:16:33.250+0000: 0.250: #8: [GC (Allocation Failure) 2022-08-01T17:16:33.251+0000: 0.250: #8: [ParNew: 9757K->1036K(9792K), 0.0016622 secs] 68783K->61918K(79248K), 0.0025883 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
21+
2022-08-01T17:16:33.254+0000: 0.253: #2: [CMS-concurrent-reset: 0.006/0.018 secs] [Times: user=0.01 sys=0.01, real=0.02 secs]

0 commit comments

Comments
 (0)