Mercurial > hg > gc-bench
view src/main/java/org/openjdk/gcbench/runtime/reads/ReadBarriersCachePressure.java @ 88:583fef4276f5
Update license and copyright headers.
author | shade |
---|---|
date | Wed, 22 Nov 2017 15:58:02 +0100 |
parents | f8496889e1ac |
children | 14c1bb4faa6e |
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.reads; 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.Benchmark) public class ReadBarriersCachePressure { @Param({"1", "16", "128", "1024"}) private int size; int mask; Object[][][] target; @Setup public void setup() { target = new Object[size][][]; for (int c = 0; c < size; c++) { target[c] = new Object[size][]; for (int j = 0; j < size; j++) { target[c][j] = new Object[size]; } } mask = size - 1; } private int s; @Benchmark @CompilerControl(CompilerControl.Mode.DONT_INLINE) public void plain() { Object[][][] tgt = target; int t = s; int m = mask; t = t * 1664525 + 1013904223; int idx1 = t & m; t = t * 1664525 + 1013904223; int idx2 = t & m; t = t * 1664525 + 1013904223; int idx3 = t & m; sink(tgt[idx1][idx2][idx3]); s = t; } @CompilerControl(CompilerControl.Mode.DONT_INLINE) private void sink(Object o) { } /* i7 4790K, 4.0 Ghz, Linux x86_64, JDK 9 (Shenandoah, 2016-09-05) Benchmark (size) Mode Cnt Score Error Units # Shenandoah ReadBarriersCachePressure.plain 1 avgt 25 7.806 ± 0.006 ns/op ReadBarriersCachePressure.plain 16 avgt 25 7.802 ± 0.003 ns/op ReadBarriersCachePressure.plain 128 avgt 25 9.220 ± 0.024 ns/op ReadBarriersCachePressure.plain 1024 avgt 25 38.590 ± 0.251 ns/op # G1 ReadBarriersCachePressure.plain 1 avgt 25 6.727 ± 0.014 ns/op ReadBarriersCachePressure.plain 16 avgt 25 6.736 ± 0.024 ns/op ReadBarriersCachePressure.plain 128 avgt 25 7.075 ± 0.015 ns/op ReadBarriersCachePressure.plain 1024 avgt 25 36.811 ± 0.259 ns/op # Parallel ReadBarriersCachePressure.plain 1 avgt 25 6.791 ± 0.026 ns/op ReadBarriersCachePressure.plain 16 avgt 25 6.780 ± 0.002 ns/op ReadBarriersCachePressure.plain 128 avgt 25 7.087 ± 0.021 ns/op ReadBarriersCachePressure.plain 1024 avgt 25 36.037 ± 0.264 ns/op This benchmark tries to validate the speculation that adding an indirection pointer before the object has the cache capacity implications: i.e. accessing the indirection pointer for the object aligned at 8 may touch the previous cache line. This does not seem to be validated, and the read barrier performance cost seems to be consistent across different sizes. */ }