Mercurial > hg > gc-bench
changeset 7:8a3abea6cd8d
Dimensional rate-limited tests.
author | shade |
---|---|
date | Mon, 28 Nov 2016 18:42:09 +0100 |
parents | 86ac912c8db1 |
children | 9b4b9f98da13 |
files | src/main/java/org/openjdk/gcbench/GCBench.java src/main/java/org/openjdk/gcbench/tests/AbstractAllocRateTest.java src/main/java/org/openjdk/gcbench/tests/AllocRateSizeTest.java src/main/java/org/openjdk/gcbench/tests/AllocRateTest.java src/main/java/org/openjdk/gcbench/tests/DimensionalTest.java |
diffstat | 5 files changed, 85 insertions(+), 163 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/org/openjdk/gcbench/GCBench.java Mon Nov 28 18:25:28 2016 +0100 +++ b/src/main/java/org/openjdk/gcbench/GCBench.java Mon Nov 28 18:42:09 2016 +0100 @@ -173,25 +173,24 @@ { String groupDescr = "Allocates the objects in almost completely empty heap, with rate limiting. "; -// tests.add(new DimensionalTest(baseOpts, org.openjdk.gcbench.alloc.ratelimited.Objects.class, -// "alloc.rated.object", groupDescr + "Allocates plain Java Objects.", -// Dimensions.heapSize(8), -// Dimensions.rate() -// )); -// -// tests.add(new DimensionalTest(baseOpts, org.openjdk.gcbench.alloc.ratelimited.PrimArray.class, -// "alloc.rated.intarray", groupDescr + "Allocates int[] arrays of different sizes.", -// Dimensions.heapSize(8), -// Dimensions.size(0, 10000, 100), -// Dimensions.rate() -// )); -// -// tests.add(new DimensionalTest(baseOpts, org.openjdk.gcbench.alloc.ratelimited.RefArray.class, -// "alloc.rated.refarray", groupDescr + "Allocates Object[] arrays of different sizes.", -// Dimensions.heapSize(8), -// Dimensions.size(0, 10000, 100), -// Dimensions.rate() -// )); + tests.add(new DimensionalTest(baseOpts, org.openjdk.gcbench.alloc.ratelimited.Objects.class, + "alloc.rated.object", groupDescr + "Allocates plain Java Objects.", + true, + Dimensions.heapSize(8) + )); + + 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(8), + Dimensions.size(1, 10000, s -> s*10) + )); + + tests.add(new DimensionalTest(baseOpts, org.openjdk.gcbench.alloc.ratelimited.RefArray.class, + "alloc.rated.refarray", groupDescr + "Allocates Object[] arrays of different sizes.", + Dimensions.heapSize(8), + Dimensions.size(1, 10000, s -> s*10) + )); } {
--- a/src/main/java/org/openjdk/gcbench/tests/AbstractAllocRateTest.java Mon Nov 28 18:25:28 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -package org.openjdk.gcbench.tests; - -import org.openjdk.jmh.results.Result; -import org.openjdk.jmh.results.RunResult; -import org.openjdk.jmh.runner.Runner; -import org.openjdk.jmh.runner.RunnerException; -import org.openjdk.jmh.runner.options.Options; -import org.openjdk.jmh.runner.options.OptionsBuilder; -import org.openjdk.jmh.runner.options.VerboseMode; - -import java.util.Map; - -public abstract class AbstractAllocRateTest extends AbstractTest { - - public AbstractAllocRateTest(Options baseOpts, String label, Class<?> benchmark, String description) { - super(baseOpts, label, benchmark, description); - } - - private int calibrateRate(Class<?> benchmark, int size) { - try { - Options opts = new OptionsBuilder() - .parent(baseOpts) - .include(benchmark.getName()) - .param("size", String.valueOf(size)) - .param("rate", String.valueOf(Integer.MAX_VALUE)) - .build(); - - RunResult result = new Runner(opts).runSingle(); - return (int) result.getPrimaryResult().getScore(); - } catch (RunnerException e) { - return 0; - } - } - - public void doRun_AllocRateX(Class<?> benchmark, Options baseOpts) { - pw.printf("%-10s %-20s %-45s %-45s %-52s %-52s %n", - "size", - "target rate", - "actual rate", - "allocation rate", - "pauses (sum, 99%, 99.9%, 99.99%)", - "ttsp (sum, 99%, 99.9%, 99.99%)" - ); - - for (int size = 1; size <= 1000000; size *= 100) { - int maxRate = calibrateRate(benchmark, size); - - pw.println(); - for (int rate = maxRate / 10; rate <= maxRate; rate += maxRate / 10) { - Options opts = new OptionsBuilder() - .parent(baseOpts) - .include(benchmark.getName()) - .param("size", String.valueOf(size)) - .param("rate", String.valueOf(rate)) - .build(); - try { - RunResult result = new Runner(opts).runSingle(); - - Result prim = result.getPrimaryResult(); - Map<String, Result> sec = result.getSecondaryResults(); - - pw.printf("%-10d %-20d %-45s %-45s %12s %12s %12s %12s %12s %12s %12s %12s %n", - size, - rate, - 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) { - // - } - } - - } - } - -}
--- a/src/main/java/org/openjdk/gcbench/tests/AllocRateSizeTest.java Mon Nov 28 18:25:28 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -package org.openjdk.gcbench.tests; - -import org.openjdk.jmh.runner.options.Options; -import org.openjdk.jmh.runner.options.OptionsBuilder; - -public class AllocRateSizeTest extends AbstractAllocRateTest { - public AllocRateSizeTest(Options baseOpts, Class<?> benchmark, String label, String description) { - super(baseOpts, label, benchmark, description); - } - - @Override - protected void doRun() { - for (int size = 1; size <= 1000000; size *= 100) { - pw.println(); - pw.println("size = " + size); - pw.println(); - Options opts = new OptionsBuilder() - .parent(baseOpts) - .param("size", String.valueOf(size)) - .build(); - doRun_AllocRateX(benchmark, opts); - } - } -}
--- a/src/main/java/org/openjdk/gcbench/tests/AllocRateTest.java Mon Nov 28 18:25:28 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -package org.openjdk.gcbench.tests; - -import org.openjdk.jmh.runner.options.Options; - -public class AllocRateTest extends AbstractAllocRateTest { - public AllocRateTest(Options baseOpts, Class<?> benchmark, String label, String description) { - super(baseOpts, label, benchmark, description); - } - - @Override - protected void doRun() { - doRun_AllocRateX(benchmark, baseOpts); - } -}
--- a/src/main/java/org/openjdk/gcbench/tests/DimensionalTest.java Mon Nov 28 18:25:28 2016 +0100 +++ b/src/main/java/org/openjdk/gcbench/tests/DimensionalTest.java Mon Nov 28 18:42:09 2016 +0100 @@ -15,11 +15,19 @@ public class DimensionalTest extends AbstractTest { private final Dimension[] dimensions; + private final boolean rated; public DimensionalTest(Options baseOpts, Class<?> benchmark, String label, String description, Dimension... dimensions) { + this(baseOpts, benchmark, label, description, false, dimensions); + } + + public DimensionalTest(Options baseOpts, Class<?> benchmark, String label, String description, + boolean rated, + Dimension... dimensions) { super(baseOpts, label, benchmark, description); this.dimensions = dimensions; + this.rated = rated; } @Override @@ -36,6 +44,10 @@ pw.printf("%-10s ", d.label()); } + if (rated) { + pw.printf("%20s ", "rate"); + } + pw.printf("%-45s %-45s %-52s %-52s %n", "performance", "allocation rate", @@ -69,32 +81,65 @@ } } - Options opts = builder.build(); - try { - RunResult result = new Runner(opts).runSingle(); - Result prim = result.getPrimaryResult(); - Map<String, Result> sec = result.getSecondaryResults(); + if (rated) { + int maxRate = calibrateRate(builder.build()); + for (int rate = maxRate / 10; rate <= maxRate; rate += maxRate / 10) { + Options opts = new OptionsBuilder() + .parent(builder.build()) + .param("rate", String.valueOf(rate)) + .build(); + runWith(values, opts, rate); + } + } else { + runWith(values, builder.build(), 0); + } + } + } - for (int v : values.values) { - pw.printf("%-10s ", v); - } + private int calibrateRate(Options base) { + try { + Options opts = new OptionsBuilder() + .parent(base) + .param("rate", String.valueOf(Integer.MAX_VALUE)) + .build(); + + RunResult result = new Runner(opts).runSingle(); + return (int) result.getPrimaryResult().getScore(); + } catch (RunnerException e) { + return 0; + } + } - pw.printf("%-45s %-45s %12s %12s %12s %12s %12s %12s %12s %12s %n", - 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) { - // do nothing + private void runWith(DimensionValues values, Options opts, int rate) { + try { + RunResult result = new Runner(opts).runSingle(); + + Result prim = result.getPrimaryResult(); + Map<String, Result> sec = result.getSecondaryResults(); + + for (int v : values.values) { + pw.printf("%-10s ", v); + } + + if (rated) { + pw.printf("%20s ", rate); } + + pw.printf("%-45s %-45s %12s %12s %12s %12s %12s %12s %12s %12s %n", + 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) { + // do nothing } }