changeset 44:25f22a0b9311

Step heap sizes as power of two.
author shade
date Thu, 08 Dec 2016 11:30:54 +0100
parents 198cdbd1c4e8
children 9bdd6c03b353
files src/main/java/org/openjdk/gcbench/GCBench.java src/main/java/org/openjdk/gcbench/MaxHeapDetector.java src/main/java/org/openjdk/gcbench/tests/Dimensions.java src/main/java/org/openjdk/gcbench/tests/Sequence.java
diffstat 4 files changed, 28 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/org/openjdk/gcbench/GCBench.java	Wed Dec 07 09:24:23 2016 +0100
+++ b/src/main/java/org/openjdk/gcbench/GCBench.java	Thu Dec 08 11:30:54 2016 +0100
@@ -155,20 +155,20 @@
             tests.add(new DimensionalTest(baseOpts, org.openjdk.gcbench.alloc.plain.Objects.class,
                     "alloc.peak.object", groupDescr + "Allocates plain Java Objects.",
                     Dimensions.threads(),
-                    Dimensions.heapSize(4)
+                    Dimensions.heapSize(Sequence.powersOfTwo_WithMax(1024, MaxHeapDetector.MAX_HEAP))
             ));
 
             tests.add(new DimensionalTest(baseOpts, org.openjdk.gcbench.alloc.plain.PrimArray.class,
                     "alloc.peak.intarray", groupDescr + "Allocates int[] arrays of different sizes.",
                     Dimensions.threads(),
-                    Dimensions.heapSize(4),
+                    Dimensions.heapSize(Sequence.powersOfTwo_WithMax(1024, MaxHeapDetector.MAX_HEAP)),
                     Dimensions.size(Sequence.powersOfTen(1, 10_000_000))
             ));
 
             tests.add(new DimensionalTest(baseOpts, org.openjdk.gcbench.alloc.plain.RefArray.class,
                     "alloc.peak.refarray", groupDescr + "Allocates Object[] arrays of different sizes.",
                     Dimensions.threads(),
-                    Dimensions.heapSize(4),
+                    Dimensions.heapSize(Sequence.powersOfTwo_WithMax(1024, MaxHeapDetector.MAX_HEAP)),
                     Dimensions.size(Sequence.powersOfTen(1, 10_000_000))
             ));
         }
@@ -181,20 +181,20 @@
             tests.add(new DimensionalTest(baseOpts, org.openjdk.gcbench.alloc.ratelimited.Objects.class,
                     "alloc.rated.object", groupDescr + "Allocates plain Java Objects.",
                     true,
-                    Dimensions.heapSize(4)
+                    Dimensions.heapSize(Sequence.powersOfTwo_WithMax(1024, MaxHeapDetector.MAX_HEAP))
             ));
 
             tests.add(new DimensionalTest(baseOpts, org.openjdk.gcbench.alloc.ratelimited.PrimArray.class,
                     "alloc.rated.intarray", groupDescr + "Allocates int[] arrays of different sizes.",
                     true,
-                    Dimensions.heapSize(4),
+                    Dimensions.heapSize(Sequence.powersOfTwo_WithMax(1024, MaxHeapDetector.MAX_HEAP)),
                     Dimensions.size(Sequence.powersOfTen(1, 10_000_000))
             ));
 
             tests.add(new DimensionalTest(baseOpts, org.openjdk.gcbench.alloc.ratelimited.RefArray.class,
                     "alloc.rated.refarray", groupDescr + "Allocates Object[] arrays of different sizes.",
                     true,
-                    Dimensions.heapSize(4),
+                    Dimensions.heapSize(Sequence.powersOfTwo_WithMax(1024, MaxHeapDetector.MAX_HEAP)),
                     Dimensions.size(Sequence.powersOfTen(1, 10_000_000))
             ));
         }
@@ -205,19 +205,19 @@
 
             tests.add(new DimensionalTest(baseOpts, org.openjdk.gcbench.retain.RefArray.class,
                     "retain.array", groupDesc + "Retains an empty reference array of given size.",
-                    Dimensions.heapSize(4),
+                    Dimensions.heapSize(Sequence.powersOfTwo_WithMax(1024, MaxHeapDetector.MAX_HEAP)),
                     Dimensions.size(Sequence.powersOfTen_Sub(100_000, 100_000_000))
             ));
 
             tests.add(new DimensionalTest(baseOpts, org.openjdk.gcbench.retain.LinkedLists.class,
                     "retain.linkedlist", groupDesc + "Retains an empty linked list of given size.",
-                    Dimensions.heapSize(4),
+                    Dimensions.heapSize(Sequence.powersOfTwo_WithMax(1024, MaxHeapDetector.MAX_HEAP)),
                     Dimensions.size(Sequence.powersOfTen_Sub(100_000, 100_000_000))
             ));
 
             tests.add(new DimensionalTest(baseOpts, org.openjdk.gcbench.retain.Tree.class,
                     "retain.tree", groupDesc + "Retains an empty tree of given size.",
-                    Dimensions.heapSize(4),
+                    Dimensions.heapSize(Sequence.powersOfTwo_WithMax(1024, MaxHeapDetector.MAX_HEAP)),
                     Dimensions.size(Sequence.powersOfTen_Sub(100_000, 100_000_000))
             ));
         }
@@ -229,21 +229,21 @@
             tests.add(new DimensionalTest(baseOpts, org.openjdk.gcbench.fragger.ArrayFragger.class,
                     "fragger.array", groupDescr + "Retains a single large reference array.",
                     true,
-                    Dimensions.heapSize(4),
+                    Dimensions.heapSize(Sequence.powersOfTwo_WithMax(1024, MaxHeapDetector.MAX_HEAP)),
                     Dimensions.lds(4)
             ));
 
             tests.add(new DimensionalTest(baseOpts, org.openjdk.gcbench.fragger.TreeFragger.class,
                     "fragger.tree", groupDescr + "Retains a binary tree of Nodes.",
                     true,
-                    Dimensions.heapSize(4),
+                    Dimensions.heapSize(Sequence.powersOfTwo_WithMax(1024, MaxHeapDetector.MAX_HEAP)),
                     Dimensions.lds(4)
             ));
 
             tests.add(new DimensionalTest(baseOpts, org.openjdk.gcbench.fragger.LinkedListFragger.class,
                     "fragger.linkedlist", groupDescr + "Retains a LinkedList.",
                     true,
-                    Dimensions.heapSize(4),
+                    Dimensions.heapSize(Sequence.powersOfTwo_WithMax(1024, MaxHeapDetector.MAX_HEAP)),
                     Dimensions.lds(4)
             ));
         }
@@ -253,7 +253,7 @@
 
             tests.add(new DimensionalTest(baseOpts, org.openjdk.gcbench.sieve.Objects.class,
                     "sieve.object", groupDescr + "Allocates Java Objects.",
-                    Dimensions.heapSize(8),
+                    Dimensions.heapSize(Sequence.powersOfTwo_WithMax(1024, MaxHeapDetector.MAX_HEAP)),
                     Dimensions.size(Sequence.powersOfTen_Sub(1, 10_000))
             ));
         }
--- a/src/main/java/org/openjdk/gcbench/MaxHeapDetector.java	Wed Dec 07 09:24:23 2016 +0100
+++ b/src/main/java/org/openjdk/gcbench/MaxHeapDetector.java	Thu Dec 08 11:30:54 2016 +0100
@@ -23,7 +23,7 @@
         boolean progress;
         do {
             progress = false;
-            for (int incr = 100; incr < Integer.MAX_VALUE; incr *= 2) {
+            for (int incr = 1000; incr < Integer.MAX_VALUE; incr *= 2) {
                 int heapGB = baseHeapMB + incr;
                 pw.print(heapGB + "? ");
                 pw.flush();
--- a/src/main/java/org/openjdk/gcbench/tests/Dimensions.java	Wed Dec 07 09:24:23 2016 +0100
+++ b/src/main/java/org/openjdk/gcbench/tests/Dimensions.java	Thu Dec 08 11:30:54 2016 +0100
@@ -4,13 +4,13 @@
 
 public class Dimensions {
 
-    public static Dimension heapSize(int min, int max, int step) {
-        return new Dimension(DimensionType.HEAPSIZE, Sequence.steps(min, max, step));
+    public static Dimension heapSize(int steps) {
+        int maxHeap = MaxHeapDetector.MAX_HEAP;
+        return new Dimension(DimensionType.HEAPSIZE, Sequence.steps(maxHeap / 16, maxHeap - maxHeap / 16, steps));
     }
 
-    public static Dimension heapSize(int steps) {
-        int maxHeap = MaxHeapDetector.MAX_HEAP;
-        return heapSize(maxHeap / 16, maxHeap - maxHeap / 16, steps);
+    public static Dimension heapSize(Sequence seq) {
+        return new Dimension(DimensionType.HEAPSIZE, seq);
     }
 
     public static Dimension lds(int steps) {
--- a/src/main/java/org/openjdk/gcbench/tests/Sequence.java	Wed Dec 07 09:24:23 2016 +0100
+++ b/src/main/java/org/openjdk/gcbench/tests/Sequence.java	Thu Dec 08 11:30:54 2016 +0100
@@ -39,6 +39,15 @@
         return new Sequence("[" + min + ", " + max + "], power-of-two steps", vs);
     }
 
+    public static Sequence powersOfTwo_WithMax(int min, int max) {
+        List<Object> vs = new ArrayList<>();
+        for (int v = min; v < max; v *= 2) {
+            vs.add(v);
+        }
+        vs.add(max);
+        return new Sequence("[" + min + ", " + max + "], power-of-two steps, with additional max", vs);
+    }
+
     public static Sequence steps(int min, int max, int steps) {
         List<Object> vs = new ArrayList<>();
         int stepSize = (max - min) / steps;