changeset 3:b993a8a07b28

Mark tests
author shade
date Fri, 25 Nov 2016 16:08:36 +0100
parents 89dd4770a404
children 985f404de0a8
files src/main/java/org/openjdk/gcbench/GCBench.java src/main/java/org/openjdk/gcbench/mark/ArrayLists.java
diffstat 2 files changed, 104 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/org/openjdk/gcbench/GCBench.java	Thu Nov 24 19:47:31 2016 +0100
+++ b/src/main/java/org/openjdk/gcbench/GCBench.java	Fri Nov 25 16:08:36 2016 +0100
@@ -7,6 +7,7 @@
 import org.openjdk.gcbench.alloc.ratelimited.PrimArray;
 import org.openjdk.gcbench.alloc.ratelimited.RefArray;
 import org.openjdk.gcbench.fragger.ArrayFragger;
+import org.openjdk.gcbench.mark.ArrayLists;
 import org.openjdk.gcbench.roots.StringTableRoots;
 import org.openjdk.gcbench.roots.Synchronizers;
 import org.openjdk.gcbench.util.Dummy;
@@ -23,6 +24,7 @@
 
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
@@ -139,6 +141,7 @@
         fraggers,
         roots_synch,
         roots_strings,
+        mark_arraylist,
     }
 
     public enum Mode {
@@ -164,12 +167,76 @@
                 case roots_strings:
                     runRoots_Strings();
                     break;
+                case mark_arraylist:
+                    runMark_ArrayList();
+                    break;
                 default:
                     throw new IllegalStateException("Unknown test: " + test);
             }
         }
     }
 
+    private void runMark_ArrayList() {
+        pw.println("=== MARK: RETAINED ARRAY LIST");
+        pw.println();
+
+        Utils.reflow(pw,
+                "The test interns the ${size} number of distinct Strings before the run, and then tries to continuously allocate Objects " +
+                        "to see if the String table affects garbage collection, e.g. by being the part of the root set.",
+                80, 2);
+        pw.println();
+
+        pw.printf("%-10s %-10s %-45s %-45s %-52s      %-52s %n",
+                "heap",
+                "size",
+                "performance",
+                "allocation rate",
+                "pauses (sum, 99%, 99.9%, 99.99%)",
+                "ttsp (sum, 99%, 99.9%, 99.99%)"
+        );
+
+
+        int margin = maxHeapMB / 8;
+        int step = maxHeapMB / 8;
+        for (int heapMB = margin; heapMB <= maxHeapMB - margin; heapMB += step) {
+            pw.println();
+            for (int size = 0; size <= 30_000_000; size += 1_000_000) {
+                Options opts = new OptionsBuilder()
+                        .parent(baseOpts)
+                        .include(ArrayLists.class.getCanonicalName())
+                        .threads(Threads.MAX)
+                        .param("size", String.valueOf(size))
+                        .jvmArgsAppend("-Xmx" + heapMB + "m", "-Xms" + heapMB + "m")
+                        .build();
+
+                try {
+                    RunResult result = new Runner(opts).runSingle();
+
+                    Result prim = result.getPrimaryResult();
+                    Map<String, Result> sec = result.getSecondaryResults();
+
+                    pw.printf("%-10d %-10d %-45s %-45s %12s %12s %12s %12s      %12s %12s %12s %12s %n",
+                            heapMB,
+                            size,
+                            prim,
+                            sec.get("·gc.alloc.rate"),
+                            sec.get("·safepoints.pause"),
+                            sec.get("·safepoints.pause.p0.99"),
+                            sec.get("·safepoints.pause.p0.999"),
+                            sec.get("·safepoints.pause.p0.9999"),
+                            sec.get("·safepoints.ttsp"),
+                            sec.get("·safepoints.ttsp.p0.99"),
+                            sec.get("·safepoints.ttsp.p0.999"),
+                            sec.get("·safepoints.ttsp.p0.9999")
+                    );
+                } catch (RunnerException e) {
+                    // OOME, fail
+                }
+            }
+        }
+    }
+
+
     private void runRoots_Synch() {
         pw.println("=== ROOTSET: SYNCHRONIZER ROOTS");
         pw.println();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/org/openjdk/gcbench/mark/ArrayLists.java	Fri Nov 25 16:08:36 2016 +0100
@@ -0,0 +1,37 @@
+package org.openjdk.gcbench.mark;
+
+import org.openjdk.jmh.annotations.*;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
+@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
+@Fork(1)
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@Threads(Threads.MAX)
+@State(Scope.Benchmark)
+public class ArrayLists {
+
+    List<Object> list;
+
+    @Param({"100000"})
+    private int size;
+
+    @Setup
+    public void setup() {
+        list = new ArrayList<>();
+        for (int c = 0; c < size; c++) {
+            list.add(new Object());
+        }
+    }
+
+    @Benchmark
+    public Object test() {
+        // allocation pressure to trigger GCs
+        return new Object();
+    }
+
+}