Skip to content

Commit 5c88ab5

Browse files
committed
improve detection of jdk8 G1 logs
1 parent ee15cd3 commit 5c88ab5

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public DataReader getDataReader(GCResource gcResource, InputStream inStream) thr
5757
break;
5858
}
5959
}
60-
byte[] buf = new byte[ONE_KB * 3];
60+
byte[] buf = new byte[FOUR_KB];
6161
int length = in.read(buf);
6262
in.reset();
6363

@@ -161,7 +161,7 @@ else if (s.contains(" (young)") || s.contains("G1Ergonomics") || s.contains(" (m
161161
// G1 logger usually starts with "<timestamp>: [GC pause (young)...]"
162162
// but can start with <timestamp>: [G1Ergonomics (Heap Sizing) expand the heap...
163163
// with certain logging flaggs.
164-
if (getLogger().isLoggable(Level.INFO)) getLogger().info("File format: Sun 1.6.x G1 collector");
164+
if (getLogger().isLoggable(Level.INFO)) getLogger().info("File format: Sun 1.6.x .. 1.8.x G1 collector");
165165
return new DataReaderSun1_6_0G1(gcResource, in, GcLogType.SUN1_6G1);
166166
}
167167
else if (s.contains("[Times:") || s.contains("[Pause Init Mark") /* Shenandoah, -XX:-PrintGCDetails */) {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,14 @@ public void testOracleG1J8() throws Exception {
323323
assertDataReader(DataReaderSun1_6_0G1.class, dr.getClass());
324324
}
325325

326+
@Test
327+
public void testOracleG1J8_StringDeduplication() throws Exception {
328+
DataReaderFactory factory = new DataReaderFactory();
329+
DataReader dr = factory.getDataReader(new GcResourceFile("byteArray"),
330+
getInputStreamOpenJdk("SampleSun1_8_0G1StringDeduplication.txt"));
331+
assertDataReader(DataReaderSun1_6_0G1.class, dr.getClass());
332+
}
333+
326334
@Test
327335
public void testOracleShenandoahJ8Simple() throws Exception {
328336
DataReaderFactory factory = new DataReaderFactory();

0 commit comments

Comments
 (0)