From 7931b3f374132a655095a4a301233decf555d87e Mon Sep 17 00:00:00 2001 From: chewiebug Date: Mon, 22 Oct 2018 21:33:40 +0200 Subject: [PATCH] #204 add new "Pause Young (G1 Evacuation Pause)" event --- .../perf/gcviewer/model/AbstractGCEvent.java | 1 + .../gcviewer/imp/TestDataReaderUJL11G1.java | 99 +++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 src/test/java/com/tagtraum/perf/gcviewer/imp/TestDataReaderUJL11G1.java diff --git a/src/main/java/com/tagtraum/perf/gcviewer/model/AbstractGCEvent.java b/src/main/java/com/tagtraum/perf/gcviewer/model/AbstractGCEvent.java index fddb01f9..8f1f4540 100644 --- a/src/main/java/com/tagtraum/perf/gcviewer/model/AbstractGCEvent.java +++ b/src/main/java/com/tagtraum/perf/gcviewer/model/AbstractGCEvent.java @@ -628,6 +628,7 @@ public String toString() { public static final Type UJL_CMS_CONCURRENT_OLD = new Type("Old", Generation.TENURED, Concurrency.CONCURRENT, GcPattern.GC_MEMORY); // unified jvm logging g1 event types + public static final Type UJL_G1_PAUSE_YOUNG = new Type("Pause Young (G1 Evacuation Pause)", Generation.YOUNG, Concurrency.SERIAL, GcPattern.GC_MEMORY_PAUSE); public static final Type UJL_G1_PAUSE_MIXED = new Type("Pause Mixed", Generation.TENURED, Concurrency.SERIAL, GcPattern.GC_MEMORY_PAUSE); public static final Type UJL_G1_TO_SPACE_EXHAUSTED = new Type("To-space exhausted", Generation.YOUNG, Concurrency.SERIAL, GcPattern.GC); public static final Type UJL_G1_CONCURRENT_CYCLE = new Type("Concurrent Cycle", Generation.TENURED, Concurrency.CONCURRENT, GcPattern.GC_PAUSE); diff --git a/src/test/java/com/tagtraum/perf/gcviewer/imp/TestDataReaderUJL11G1.java b/src/test/java/com/tagtraum/perf/gcviewer/imp/TestDataReaderUJL11G1.java new file mode 100644 index 00000000..5d9bb04c --- /dev/null +++ b/src/test/java/com/tagtraum/perf/gcviewer/imp/TestDataReaderUJL11G1.java @@ -0,0 +1,99 @@ +package com.tagtraum.perf.gcviewer.imp; + +import static org.hamcrest.Matchers.closeTo; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.logging.Level; + +import com.tagtraum.perf.gcviewer.UnittestHelper; +import com.tagtraum.perf.gcviewer.UnittestHelper.FOLDER; +import com.tagtraum.perf.gcviewer.model.GCModel; +import com.tagtraum.perf.gcviewer.model.GCResource; +import com.tagtraum.perf.gcviewer.model.GcResourceFile; +import org.junit.Test; + +/** + * Test unified java logging G1 algorithm in OpenJDK 11 + */ +public class TestDataReaderUJL11G1 { + private GCModel getGCModelFromLogFile(String fileName) throws IOException { + return UnittestHelper.getGCModelFromLogFile(fileName, FOLDER.OPENJDK_UJL, DataReaderUnifiedJvmLogging.class); + } + + @Test + public void testDefaultsPauseYoungNormal() throws Exception { + TestLogHandler handler = new TestLogHandler(); + handler.setLevel(Level.WARNING); + GCResource gcResource = new GcResourceFile("byteArray"); + gcResource.getLogger().addHandler(handler); + InputStream in = new ByteArrayInputStream( + ("[1.113s][info][gc] GC(4) Pause Young (Normal) (G1 Evacuation Pause) 70M->70M(128M) 12.615ms") + .getBytes()); + + DataReader reader = new DataReaderUnifiedJvmLogging(gcResource, in); + GCModel model = reader.read(); + + assertThat("number of warnings", handler.getCount(), is(0)); + assertThat("number of events", model.size(), is(1)); + assertThat("pause", model.get(0).getPause(), closeTo(0.012615, 0.00000001)); + } + + @Test + public void testDefaultsPauseYoungConcurrentStart() throws Exception { + TestLogHandler handler = new TestLogHandler(); + handler.setLevel(Level.WARNING); + GCResource gcResource = new GcResourceFile("byteArray"); + gcResource.getLogger().addHandler(handler); + InputStream in = new ByteArrayInputStream( + ("[1.155s][info][gc] GC(5) Pause Young (Concurrent Start) (G1 Evacuation Pause) 84M->79M(128M) 5.960ms") + .getBytes()); + + DataReader reader = new DataReaderUnifiedJvmLogging(gcResource, in); + GCModel model = reader.read(); + + assertThat("number of warnings", handler.getCount(), is(0)); + assertThat("number of events", model.size(), is(1)); + assertThat("heap before", model.get(0).getPreUsed(), is(84 * 1024)); + } + + @Test + public void testDefaultsPauseYoungPrepareMixed() throws Exception { + TestLogHandler handler = new TestLogHandler(); + handler.setLevel(Level.WARNING); + GCResource gcResource = new GcResourceFile("byteArray"); + gcResource.getLogger().addHandler(handler); + InputStream in = new ByteArrayInputStream( + ("[2.649s][info][gc] GC(218) Pause Young (Prepare Mixed) (G1 Evacuation Pause) 81M->79M(128M) 1.322ms") + .getBytes()); + + DataReader reader = new DataReaderUnifiedJvmLogging(gcResource, in); + GCModel model = reader.read(); + + assertThat("number of warnings", handler.getCount(), is(0)); + assertThat("number of events", model.size(), is(1)); + assertThat("heap after", model.get(0).getPostUsed(), is(79 * 1024)); + } + + @Test + public void testDefaultsPauseYoungMixed() throws Exception { + TestLogHandler handler = new TestLogHandler(); + handler.setLevel(Level.WARNING); + GCResource gcResource = new GcResourceFile("byteArray"); + gcResource.getLogger().addHandler(handler); + InputStream in = new ByteArrayInputStream( + ("[2.651s][info][gc] GC(219) Pause Young (Mixed) (G1 Evacuation Pause) 84M->83M(128M) 1.599ms") + .getBytes()); + + DataReader reader = new DataReaderUnifiedJvmLogging(gcResource, in); + GCModel model = reader.read(); + + assertThat("number of warnings", handler.getCount(), is(0)); + assertThat("number of events", model.size(), is(1)); + assertThat("total heap", model.get(0).getTotal(), is(128 * 1024)); + } + +}