Skip to content

Commit 61201c4

Browse files
authored
Support to parse PrintGCID (#260)
1 parent fd90b9d commit 61201c4

File tree

5 files changed

+66
-2
lines changed

5 files changed

+66
-2
lines changed

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

+31
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,37 @@ protected String parseTypeString(String line, ParseInformation pos) throws Parse
301301
}
302302
}
303303

304+
// restriction PringGCID only for parallel scavenge collector
305+
protected void parseGcId(String line, ParseInformation pos) throws ParseException {
306+
if (!line.contains("#"))
307+
return;
308+
int i = pos.getIndex();
309+
try {
310+
// consume all leading spaces and '#'
311+
final int lineLength = line.length();
312+
final char[] lineChars = line.toCharArray();
313+
char c = lineChars[i];
314+
for (; i < lineLength; c = lineChars[++i]) {
315+
if (c != ' ' && c != '#')
316+
break;
317+
}
318+
if (i >= lineLength)
319+
throw new ParseException("Unexpected end of line.", line);
320+
// check whether the Id starts with a number
321+
// -> skip number
322+
for (; Character.isDigit(c) && i < lineLength; c = lineChars[++i]);
323+
// -> skip ':'
324+
for (; i<lineLength; c = lineChars[++i]) {
325+
if (c != ':')
326+
break;
327+
}
328+
}
329+
finally {
330+
i++;
331+
pos.setIndex(i);
332+
}
333+
}
334+
304335
protected ExtendedType parseType(String line, ParseInformation pos) throws ParseException {
305336
String typeString = parseTypeString(line, pos);
306337
return getDataReaderTools().parseType(typeString);

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

+1
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ protected AbstractGCEvent<?> parseLine(String line, ParseInformation pos) throws
620620
// pre-used->post-used, total, time
621621
ZonedDateTime datestamp = parseDatestamp(line, pos);
622622
double timestamp = getTimestamp(line, pos, datestamp);
623+
parseGcId(line, pos);
623624
ExtendedType type = parseType(line, pos);
624625
AbstractGCEvent<?> ae;
625626
if (type.getConcurrency() == Concurrency.CONCURRENT) {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ protected AbstractGCEvent<?> parseLine(String line, ParseInformation pos) throws
551551
// pre-used->post-used, total, time
552552
ZonedDateTime datestamp = parseDatestamp(line, pos);
553553
double timestamp = getTimestamp(line, pos, datestamp);
554+
parseGcId(line, pos);
554555
ExtendedType type = parseType(line, pos);
555556
// special provision for concurrent events
556557
if (type.getConcurrency() == Concurrency.CONCURRENT) {
@@ -579,8 +580,7 @@ else if (type.getCollectionType().equals(CollectionType.VM_OPERATION)) {
579580

580581
if (event.getExtendedType().getPattern() == GcPattern.GC_MEMORY_PAUSE) {
581582
setMemoryAndPauses(event, line, pos);
582-
}
583-
else {
583+
} else {
584584
event.setPause(parsePause(line, pos));
585585
}
586586
}

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

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

420+
@Test
421+
public void parallelPrintGCID() throws Exception {
422+
TestLogHandler handler = new TestLogHandler();
423+
handler.setLevel(Level.WARNING);
424+
GCResource gcResource = new GcResourceFile("SampleSun1_8_0ParallelPrintGCID.txt");
425+
gcResource.getLogger().addHandler(handler);
426+
427+
DataReader reader = getDataReader(gcResource);
428+
GCModel model = reader.read();
429+
430+
assertThat("gc count", model.size(), is(5));
431+
432+
assertEquals("number of errors", 0, handler.getCount());
433+
}
434+
420435
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
OpenJDK 64-Bit Server VM (25.71-b00) for linux-loongarch64 JRE (1.8.0-internal-loongson_2022_07_26_20_28-b00), built on Jul 26 2022 20:34:57 by "loongson" with gcc 8.3.0
2+
Memory: 16k page, physical 16539232k(15517424k free), swap 9227440k(9227440k free)
3+
CommandLine flags: -XX:InitialHeapSize=10737418240 -XX:MaxHeapSize=10737418240 -XX:MaxNewSize=9663676416 -XX:NewSize=9663676416 -XX:+PrintGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCID -XX:+PrintGCTimeStamps -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseParallelGC
4+
2022-07-26T21:00:40.750+0800: 3.117: #0: [GC (Allocation Failure) [PSYoungGen: 7077888K->222570K(8257536K)] 7077888K->222586K(9306112K), 0.5437135 secs] [Times: user=1.92 sys=0.20, real=0.55 secs]
5+
2022-07-26T21:00:45.037+0800: 7.405: #1: [GC (System.gc()) [PSYoungGen: 3729513K->98289K(8257536K)] 3729529K->98321K(9306112K), 0.1937274 secs] [Times: user=0.69 sys=0.07, real=0.19 secs]
6+
2022-07-26T21:00:45.231+0800: 7.599: #2: [Full GC (System.gc()) [PSYoungGen: 98289K->0K(8257536K)] [ParOldGen: 32K->98112K(1048576K)] 98321K->98112K(9306112K), [Metaspace: 16471K->16471K(1064960K)], 0.6492397 secs] [Times: user=1.52 sys=0.17, real=0.65 secs]
7+
2022-07-26T21:02:14.912+0800: 97.280: #3: [GC (System.gc()) [PSYoungGen: 6687404K->105989K(8257536K)] 6785517K->204182K(9306112K), 0.0216159 secs] [Times: user=0.06 sys=0.00, real=0.03 secs]
8+
2022-07-26T21:02:14.934+0800: 97.301: #4: [Full GC (System.gc()) [PSYoungGen: 105989K->0K(8257536K)] [ParOldGen: 98192K->203813K(1048576K)] 204182K->203813K(9306112K), [Metaspace: 19966K->19962K(1067008K)], 0.4555626 secs] [Times: user=1.52 sys=0.13, real=0.45 secs]
9+
Heap
10+
PSYoungGen total 8086016K, used 7277906K [0x0000000580000000, 0x00000007c0000000, 0x00000007c0000000)
11+
eden space 7013376K, 88% used [0x0000000580000000,0x00000006fabd8888,0x000000072c100000)
12+
from space 1072640K, 99% used [0x000000077e880000,0x00000007bfffc138,0x00000007c0000000)
13+
to space 1211904K, 0% used [0x000000072c100000,0x000000072c100000,0x0000000776080000)
14+
ParOldGen total 1048576K, used 370122K [0x0000000540000000, 0x0000000580000000, 0x0000000580000000)
15+
object space 1048576K, 35% used [0x0000000540000000,0x00000005569728e0,0x0000000580000000)
16+
Metaspace used 29044K, capacity 29852K, committed 29952K, reserved 1075200K
17+
class space used 3288K, capacity 3510K, committed 3584K, reserved 1048576K

0 commit comments

Comments
 (0)