Mercurial > hg > gc-bench
changeset 47:dada456637b0
Cleanup, and make sure we have error bounds in machine counters tests.
author | shade |
---|---|
date | Fri, 09 Dec 2016 15:37:18 +0100 |
parents | 6d332199876c |
children | afe1acc2f8a1 |
files | src/main/java/org/openjdk/gcbench/runtime/writes/WriteBarriersPrimitive.java src/main/java/org/openjdk/gcbench/runtime/writes/WriteBarriersRef.java src/main/java/org/openjdk/gcbench/tests/MachineCntTest.java |
diffstat | 3 files changed, 3 insertions(+), 212 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/org/openjdk/gcbench/runtime/writes/WriteBarriersPrimitive.java Thu Dec 08 17:36:31 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,96 +0,0 @@ -package org.openjdk.gcbench.runtime.writes; - -import org.openjdk.jmh.annotations.*; - -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(1) -@State(Scope.Thread) -public class WriteBarriersPrimitive { - - Target target; - int source; - - @Setup - public void setup() { - target = new Target(); - source = 42; - } - - @Benchmark - @CompilerControl(CompilerControl.Mode.DONT_INLINE) - public void test() { - target.field = source; - } - - static class Target { - int field; - } - - /* - i5 4210U, 1.7 Ghz, Linux x86_64, JDK 9 (Shenandoah, 2016-09-12) - - Benchmark Mode Cnt Score Error Units - - # Shenandoah - WriteBarriersPrimitive.test avgt 25 3.771 ± 0.010 ns/op - - # G1 - WriteBarriersPrimitive.test avgt 25 2.623 ± 0.022 ns/op - - # Parallel - WriteBarriersPrimitive.test avgt 25 2.551 ± 0.008 ns/op - - Shenandoah has to do the write barriers even for primitive stores, - in order to preserve "no writes into evacuated regions" invariant. - Other collectors do not have to do this. The write barrier code - quality may be improved to amortize the costs. - - Shenandoah: - - [Verified Entry Point] - 6.81% 8.72% 0x00007f85a58dddc0: mov %eax,-0x14000(%rsp) - 3.08% 3.37% 0x00007f85a58dddc7: push %rbp - 0.05% 0.11% 0x00007f85a58dddc8: sub $0x10,%rsp - 8.72% 7.79% 0x00007f85a58dddcc: mov -0x8(%rsi),%r10 ; <--- read barrier ($this) - 0.67% 0.50% 0x00007f85a58dddd0: mov 0x10(%r10),%r11d ; get field $target - 0.08% 0.09% 0x00007f85a58dddd4: mov 0xc(%r10),%r10d ; get field $source - 6.83% 7.37% 0x00007f85a58dddd8: test %r11d,%r11d ; null check $target - ╭ 0x00007f85a58ddddb: je 0x00007f85a58dde0e - 2.30% 0.64% │ 0x00007f85a58ddddd: shl $0x3,%r11 ; unpack $target - 0.61% 0.52% │ 0x00007f85a58ddde1: mov -0x8(%r11),%r11 ; <--- read barrier once; WHY? There is a null check before already - 0.14% 0.09% │ 0x00007f85a58ddde5: cmpb $0x0,0x3d8(%r15) ; evacuation in progress? - 6.70% 6.03% │ 0x00007f85a58ddded: mov -0x8(%r11),%r11 ; <--- read barrier twice (in sequence now) - 3.53% 1.67% │╭ 0x00007f85a58dddf1: je 0x00007f85a58dddfe - ││ 0x00007f85a58dddf3: xchg %rax,%r11 ; <--- barrier slowpath - ││ 0x00007f85a58dddf6: callq Stub::shenandoah_wb - ││ 0x00007f85a58dddfb: xchg %rax,%r11 - 0.53% 0.62% │↘ 0x00007f85a58dddfe: mov %r10d,0xc(%r11) ; actual store - 25.37% 27.26% │ 0x00007f85a58dde02: add $0x10,%rsp - 2.28% 2.20% │ 0x00007f85a58dde06: pop %rbp - 0.72% 0.03% │ 0x00007f85a58dde07: test %eax,0x11df41f3(%rip) - 0.06% 0.09% │ 0x00007f85a58dde0d: retq - - - Parallel: - - [Verified Entry Point] - 4.35% 5.11% 0x00007fc6fdaf3840: mov %eax,-0x14000(%rsp) - 10.05% 9.23% 0x00007fc6fdaf3847: push %rbp - 0.05% 0x00007fc6fdaf3848: sub $0x10,%rsp - 4.65% 4.18% 0x00007fc6fdaf384c: mov 0xc(%rsi),%r11d ; get field $source - 10.83% 9.16% 0x00007fc6fdaf3850: mov 0x10(%rsi),%r10d ; get field $target - 0.02% 0.02% 0x00007fc6fdaf3854: mov %r11d,0xc(%r12,%r10,8) ; actual field store - 14.61% 15.76% 0x00007fc6fdaf3859: add $0x10,%rsp - 0x00007fc6fdaf385d: pop %rbp - 6.13% 6.24% 0x00007fc6fdaf385e: test %eax,0x13c1a79c(%rip) - 0.02% 0x00007fc6fdaf3864: retq - - */ - -}
--- a/src/main/java/org/openjdk/gcbench/runtime/writes/WriteBarriersRef.java Thu Dec 08 17:36:31 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,114 +0,0 @@ -package org.openjdk.gcbench.runtime.writes; - -import org.openjdk.jmh.annotations.*; - -import java.util.concurrent.ThreadLocalRandom; -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(1) -@State(Scope.Thread) -public class WriteBarriersRef { - - Target target; - Target source; - - @Setup - public void setup() { - target = new Target(); - source = new Target(); - } - - @Benchmark - - public void test() { - doStore(target, source); - } - - @CompilerControl(CompilerControl.Mode.DONT_INLINE) - private void doStore(Target t, Target v) { - t.field = v; - } - - static class Target { - Object field; - } - - /* - i7 4790K, 4.0 Ghz, Linux x86_64, JDK 9 (Shenandoah, 2016-09-05) - - Benchmark Mode Cnt Score Error Units - - # Shenandoah - WriteBarriersRef.test avgt 25 3.222 ± 0.003 ns/op - - # G1 - WriteBarriersRef.test avgt 25 2.341 ± 0.005 ns/op - - # Parallel - WriteBarriersRef.test avgt 25 2.176 ± 0.006 ns/op - - The difference is in a more complicated write barrier that may be improved a little with more - implicit null checks and code quality tuneups. - - Shenandoah: - - [Verified Entry Point] - 5.12% 4.76% 0x00007f51f0845dc0: mov %eax,-0x14000(%rsp) - 3.00% 2.29% 0x00007f51f0845dc7: push %rbp - 0.08% 0.05% 0x00007f51f0845dc8: sub $0x10,%rsp - 4.90% 3.93% 0x00007f51f0845dcc: mov -0x8(%rsi),%r10 ; <--- read barrier - 2.34% 0.63% 0x00007f51f0845dd0: mov 0xc(%r10),%r11d ; get field $target - 0.05% 0.08% 0x00007f51f0845dd4: mov 0x10(%r10),%r10d ; <-- get field $source - 4.68% 5.24% 0x00007f51f0845dd8: test %r11d,%r11d ; nullcheck $target <--- NOT IMPLICIT? - 0x00007f51f0845ddb: je 0x00007f51f0845e6c - 0.05% 0.03% 0x00007f51f0845de1: test %r10d,%r10d ; nullcheck $source <--- NOT IMPLICIT? - ╭ 0x00007f51f0845de4: je 0x00007f51f0845e33 - 2.56% 0.19% │ 0x00007f51f0845de6: shl $0x3,%r10 ; unpack $source - 0.03% │ 0x00007f51f0845dea: mov -0x8(%r10),%rbx ; <--- HUH? Is this a null check trap? Unpacking is not needed then. - 6.58% 5.81% │ ↗ 0x00007f51f0845dee: lea (%r12,%r11,8),%r10 ; unpack $target - │ │ 0x00007f51f0845df2: mov -0x8(%r10),%rbp ; <--- read barrier - 2.00% 0.06% │ │ 0x00007f51f0845df6: cmpb $0x0,0x3d8(%r15) ; "evacuation in progress?" - │ │ 0x00007f51f0845dfe: mov -0x8(%r10),%rbp ; <--- read barrier again (in sequence) - 6.46% 6.90% │╭ │ 0x00007f51f0845e02: je 0x00007f51f0845e0f ; no evacuation? jump over the barrier <--- SHOULD MOVE TO SLOWPATH - ││ │ 0x00007f51f0845e04: xchg %rax,%rbp - ││ │ 0x00007f51f0845e07: callq Stub::shenandoah_wb ; {runtime_call StubRoutines (2)} - ││ │ 0x00007f51f0845e0c: xchg %rax,%rbp - │↘ │ 0x00007f51f0845e0f: movsbl 0x378(%r15),%r11d ; SATB check and jump - 1.29% 1.33% │ │ 0x00007f51f0845e17: test %r11d,%r11d - │ ╭│ 0x00007f51f0845e1a: jne 0x00007f51f0845e37 - │ ││↗ 0x00007f51f0845e1c: mov %rbx,%r10 ; packing $source (note, we unpacked before) - 6.61% 6.90% │ │││ 0x00007f51f0845e1f: shr $0x3,%r10 - │ │││ 0x00007f51f0845e23: mov %r10d,0xc(%rbp) ; field store! - 18.55% 20.33% │ │││ 0x00007f51f0845e27: add $0x10,%rsp - │ │││ 0x00007f51f0845e2b: pop %rbp - 2.93% 3.37% │ │││ 0x00007f51f0845e2c: test %eax,0x11e691ce(%rip) - │ │││ 0x00007f51f0845e32: retq - - - Parallel: - - [Verified Entry Point] - 3.65% 4.20% 0x00007f5169af3040: mov %eax,-0x14000(%rsp) - 9.31% 9.50% 0x00007f5169af3047: push %rbp - 0x00007f5169af3048: sub $0x10,%rsp - 3.17% 4.53% 0x00007f5169af304c: mov 0x10(%rsi),%r11d ; get field $source - 8.67% 7.93% 0x00007f5169af3050: mov 0xc(%rsi),%r10d ; get field $target - ╭ 0x00007f5169af3054: mov %r11d,0xc(%r12,%r10,8) ; field store, implicit exception: dispatches to 0x00007f5169af307b - 8.29% 8.77% │ 0x00007f5169af3059: shl $0x3,%r10 ; card mark update - │ 0x00007f5169af305d: shr $0x9,%r10 - 6.58% 5.85% │ 0x00007f5169af3061: movabs $0x7f517632f000,%r11 - │ 0x00007f5169af306b: mov %r12b,(%r11,%r10,1) - 11.76% 11.87% │ 0x00007f5169af306f: add $0x10,%rsp ; epilog - │ 0x00007f5169af3073: pop %rbp - 5.28% 5.76% │ 0x00007f5169af3074: test %eax,0x145b3f86(%rip) - │ 0x00007f5169af307a: retq - ↘ 0x00007f5169af307b: mov $0xfffffff6,%esi - - */ - -}
--- a/src/main/java/org/openjdk/gcbench/tests/MachineCntTest.java Thu Dec 08 17:36:31 2016 +0100 +++ b/src/main/java/org/openjdk/gcbench/tests/MachineCntTest.java Fri Dec 09 15:37:18 2016 +0100 @@ -49,6 +49,7 @@ ChainedOptionsBuilder builder = new OptionsBuilder() .parent(baseOpts) .threads(1) + .forks(3) .addProfiler(LinuxPerfNormProfiler.class); @@ -118,9 +119,9 @@ private String shortVal(Result r) { if (r != null) { if (!Double.isNaN(r.getScoreError())) { - return String.format("%.3f ± %.3f %s", r.getScore(), r.getScoreError(), r.getScoreUnit()); + return String.format("%.2f ± %.2f %s", r.getScore(), r.getScoreError(), r.getScoreUnit()); } else { - return String.format("%.3f %s", r.getScore(), r.getScoreUnit()); + return String.format("%.2f %s", r.getScore(), r.getScoreUnit()); } } else { return "-";