Mercurial > hg > gc-bench
view src/main/java/org/openjdk/gcbench/runtime/cmp/ACmpBarriersRandom.java @ 88:583fef4276f5
Update license and copyright headers.
author | shade |
---|---|
date | Wed, 22 Nov 2017 15:58:02 +0100 |
parents | f8496889e1ac |
children |
line wrap: on
line source
/* * Copyright (c) 2017, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.gcbench.runtime.cmp; import org.openjdk.jmh.annotations.*; import java.util.Random; import java.util.concurrent.TimeUnit; @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(value = 10, jvmArgsAppend = {"-Xmx2g", "-Xms2g", "-XX:-TieredCompilation"}) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Threads(1) @State(Scope.Thread) public class ACmpBarriersRandom { @Param("10000") private int size; Object[] targets; @Setup(Level.Iteration) public void setup() { Object[] cases = new Object[] {new Object(), new Object(), null}; targets = new Object[size]; Random r = new Random(); for (int c = 0; c < size; c++) { targets[c] = cases[r.nextInt(cases.length)]; } } @Benchmark public void test() { Object[] targets = this.targets; for (int c = 0; c < size - 1; c++) { acmp(targets[c], targets[c+1]); } } @CompilerControl(CompilerControl.Mode.DONT_INLINE) private boolean acmp(Object t1, Object t2) { return t1 == t2; } /* i7 4790K, 4.0 Ghz, Linux x86_64, JDK 9 (Shenandoah, 2016-09-05) Benchmark (size) Mode Cnt Score Error Units # Shenandoah ACmpBarriersRandom.test 10000 avgt 50 81.733 ± 0.237 us/op # G1 ACmpBarriersRandom.test 10000 avgt 50 33.487 ± 0.082 us/op # Parallel ACmpBarriersRandom.test 10000 avgt 50 33.461 ± 0.049 us/op The difference is explained by a more complicated acmp barrier that needs to handle false negatives caused by concurrent evacuation. Parallel and G1: [Verified Entry Point] 2.62% 3.27% 0x00007f03c5af48c0: sub $0x18,%rsp 5.92% 5.57% 0x00007f03c5af48c7: mov %rbp,0x10(%rsp) 1.39% 1.64% 0x00007f03c5af48cc: xor %r10d,%r10d 1.67% 1.54% 0x00007f03c5af48cf: mov $0x1,%eax 4.45% 5.35% 0x00007f03c5af48d4: cmp %rcx,%rdx ; compare 0.68% 1.07% 0x00007f03c5af48d7: cmovne %r10d,%eax ; choose 0 or 1 3.11% 3.15% 0x00007f03c5af48db: add $0x10,%rsp 4.07% 6.03% 0x00007f03c5af48df: pop %rbp 1.06% 1.66% 0x00007f03c5af48e0: test %eax,0x1326a71a(%rip) 1.30% 1.22% 0x00007f03c5af48e6: retq Shenandoah: [Verified Entry Point] 3.24% 1.91% 0x00007f11fd2addc0: sub $0x18,%rsp 0.35% 1.02% 0x00007f11fd2addc7: mov %rbp,0x10(%rsp) 0.12% 0.13% 0x00007f11fd2addcc: cmp %rcx,%rdx ; compare ╭ 0x00007f11fd2addcf: je 0x00007f11fd2adde3 2.79% 2.58% │ 0x00007f11fd2addd1: test %rcx,%rcx ; null check t1 │╭ 0x00007f11fd2addd4: je 0x00007f11fd2addfe 1.74% 2.39% ││ 0x00007f11fd2addd6: mov -0x8(%rcx),%rcx ; read barrier t1 5.90% 8.70% ││ ↗ 0x00007f11fd2addda: test %rdx,%rdx ; null check t2 ││╭│ 0x00007f11fd2adddd: je 0x00007f11fd2ade02 0.25% 0.43% ││││ 0x00007f11fd2adddf: mov -0x8(%rdx),%rdx ; read barrier t2 7.54% 8.56% ↘│││↗ 0x00007f11fd2adde3: xor %r11d,%r11d ; same as Parallel/G1: 1.02% 1.02% ││││ 0x00007f11fd2adde6: mov $0x1,%eax 4.91% 8.30% ││││ 0x00007f11fd2addeb: cmp %rcx,%rdx ; <--- redundant compare for the "==" path, can reuse the first one 1.50% 2.22% ││││ 0x00007f11fd2addee: cmovne %r11d,%eax ; choose 0 or 1 5.38% 9.70% ││││ 0x00007f11fd2addf2: add $0x10,%rsp 0.47% 0.47% ││││ 0x00007f11fd2addf6: pop %rbp 5.10% 5.67% ││││ 0x00007f11fd2addf7: test %eax,0x11df7203(%rip) 1.00% 0.69% ││││ 0x00007f11fd2addfd: retq 1.79% 2.44% ↘│││ 0x00007f11fd2addfe: xor %ecx,%ecx ; <--- redundant branch, can reuse %rcx above, proven to be zero 0.50% 0.54% │╰│ 0x00007f11fd2ade00: jmp 0x00007f11fd2addda 0.02% 0.05% ↘ │ 0x00007f11fd2ade02: xor %edx,%edx ; <--- redundant branch, can reuse %rdx above, proven to be zero 0.48% 0.43% ╰ 0x00007f11fd2ade04: jmp 0x00007f11fd2adde3 */ }