mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-15 08:34:30 +02:00
8180450: secondary_super_cache does not scale well
Co-authored-by: Vladimir Ivanov <vlivanov@openjdk.org> Reviewed-by: kvn, vlivanov, dlong
This commit is contained in:
parent
bfff02eef6
commit
f11a496de6
40 changed files with 2209 additions and 48 deletions
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* Copyright Amazon.com Inc. or its affiliates. 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.
|
||||
*
|
||||
* 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.bench.vm.compiler;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.infra.Blackhole;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Warmup(iterations = 5, time = 300, timeUnit = TimeUnit.MILLISECONDS)
|
||||
@Measurement(iterations = 5, time = 300, timeUnit = TimeUnit.MILLISECONDS)
|
||||
@Fork(value = 3, jvmArgsAppend = {"-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1"})
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@Threads(1)
|
||||
@State(Scope.Benchmark)
|
||||
public class SecondarySuperCacheHits {
|
||||
|
||||
// This test targets C1 specifically, to enter the interesting code path
|
||||
// without heavily optimizing compiler like C2 optimizing based on profiles,
|
||||
// or folding the instanceof checks.
|
||||
|
||||
// The test verifies what happens on a happy path, when we can actually cache
|
||||
// the last super and use it effectively.
|
||||
|
||||
interface I01 {}
|
||||
interface I02 {}
|
||||
interface I03 {}
|
||||
interface I04 {}
|
||||
interface I05 {}
|
||||
interface I06 {}
|
||||
interface I07 {}
|
||||
interface I08 {}
|
||||
interface I09 {}
|
||||
interface I10 {}
|
||||
interface I11 {}
|
||||
interface I12 {}
|
||||
interface I13 {}
|
||||
interface I14 {}
|
||||
interface I15 {}
|
||||
interface I16 {}
|
||||
interface I17 {}
|
||||
interface I18 {}
|
||||
interface I19 {}
|
||||
interface I20 {}
|
||||
|
||||
class B {}
|
||||
class C1 extends B implements I01, I02, I03, I04, I05, I06, I07, I08, I09, I10, I11, I12, I13, I14, I15, I16, I17, I18, I19, I20 {}
|
||||
|
||||
volatile B o;
|
||||
|
||||
@Setup
|
||||
public void setup() {
|
||||
o = new C1();
|
||||
}
|
||||
|
||||
static final int ITERS = 10000;
|
||||
|
||||
@Benchmark
|
||||
@OperationsPerInvocation(20*ITERS)
|
||||
public void test(Blackhole bh) {
|
||||
for (int c = 0; c < ITERS; c++) bh.consume(o instanceof I01);
|
||||
for (int c = 0; c < ITERS; c++) bh.consume(o instanceof I02);
|
||||
for (int c = 0; c < ITERS; c++) bh.consume(o instanceof I03);
|
||||
for (int c = 0; c < ITERS; c++) bh.consume(o instanceof I04);
|
||||
for (int c = 0; c < ITERS; c++) bh.consume(o instanceof I05);
|
||||
|
||||
for (int c = 0; c < ITERS; c++) bh.consume(o instanceof I06);
|
||||
for (int c = 0; c < ITERS; c++) bh.consume(o instanceof I07);
|
||||
for (int c = 0; c < ITERS; c++) bh.consume(o instanceof I08);
|
||||
for (int c = 0; c < ITERS; c++) bh.consume(o instanceof I09);
|
||||
for (int c = 0; c < ITERS; c++) bh.consume(o instanceof I10);
|
||||
|
||||
for (int c = 0; c < ITERS; c++) bh.consume(o instanceof I11);
|
||||
for (int c = 0; c < ITERS; c++) bh.consume(o instanceof I12);
|
||||
for (int c = 0; c < ITERS; c++) bh.consume(o instanceof I13);
|
||||
for (int c = 0; c < ITERS; c++) bh.consume(o instanceof I14);
|
||||
for (int c = 0; c < ITERS; c++) bh.consume(o instanceof I15);
|
||||
|
||||
for (int c = 0; c < ITERS; c++) bh.consume(o instanceof I16);
|
||||
for (int c = 0; c < ITERS; c++) bh.consume(o instanceof I17);
|
||||
for (int c = 0; c < ITERS; c++) bh.consume(o instanceof I18);
|
||||
for (int c = 0; c < ITERS; c++) bh.consume(o instanceof I19);
|
||||
for (int c = 0; c < ITERS; c++) bh.consume(o instanceof I20);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Copyright Amazon.com Inc. or its affiliates. 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.
|
||||
*
|
||||
* 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.bench.vm.compiler;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.infra.Blackhole;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Warmup(iterations = 5, time = 300, timeUnit = TimeUnit.MILLISECONDS)
|
||||
@Measurement(iterations = 5, time = 300, timeUnit = TimeUnit.MILLISECONDS)
|
||||
@Fork(value = 3, jvmArgsAppend = {"-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1"})
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@Threads(Threads.MAX)
|
||||
@State(Scope.Benchmark)
|
||||
public class SecondarySuperCacheInterContention {
|
||||
|
||||
// This test targets C1 specifically, to enter the interesting code path
|
||||
// without heavily optimizing compiler like C2 optimizing based on profiles,
|
||||
// or folding the instanceof checks.
|
||||
|
||||
// The test verifies what happens on unhappy path, when we contend a lot over
|
||||
// the secondary super cache, where different threads want to update the cache
|
||||
// with different value. In tihs test, every thread comes with its own stable
|
||||
// cached value. Meaning, this tests the INTER-thread contention.
|
||||
|
||||
interface IA {}
|
||||
interface IB {}
|
||||
class B {}
|
||||
class C1 extends B implements IA, IB {}
|
||||
class C2 extends B implements IA, IB {}
|
||||
|
||||
volatile B o1, o2;
|
||||
|
||||
@Setup
|
||||
public void setup() {
|
||||
o1 = new C1();
|
||||
o2 = new C2();
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
@OperationsPerInvocation(2)
|
||||
@Group("test")
|
||||
@GroupThreads(1)
|
||||
public void t1(Blackhole bh) {
|
||||
bh.consume(o1 instanceof IA);
|
||||
bh.consume(o2 instanceof IA);
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
@OperationsPerInvocation(2)
|
||||
@Group("test")
|
||||
@GroupThreads(1)
|
||||
public void t2(Blackhole bh) {
|
||||
bh.consume(o1 instanceof IB);
|
||||
bh.consume(o2 instanceof IB);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright Amazon.com Inc. or its affiliates. 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.
|
||||
*
|
||||
* 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.bench.vm.compiler;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.infra.Blackhole;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Warmup(iterations = 5, time = 300, timeUnit = TimeUnit.MILLISECONDS)
|
||||
@Measurement(iterations = 5, time = 300, timeUnit = TimeUnit.MILLISECONDS)
|
||||
@Fork(value = 3, jvmArgsAppend = {"-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1"})
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@Threads(Threads.MAX)
|
||||
@State(Scope.Benchmark)
|
||||
public class SecondarySuperCacheIntraContention {
|
||||
|
||||
// This test targets C1 specifically, to enter the interesting code path
|
||||
// without heavily optimizing compiler like C2 optimizing based on profiles,
|
||||
// or folding the instanceof checks.
|
||||
|
||||
// The test verifies what happens on unhappy path, when we contend a lot over
|
||||
// the secondary super cache, where different threads want to update the cache
|
||||
// with different value. In this test, every thread comes with its own contending
|
||||
// value. Meaning, this tests the INTRA-thread contention.
|
||||
|
||||
interface IA {}
|
||||
interface IB {}
|
||||
class B {}
|
||||
class C1 extends B implements IA, IB {}
|
||||
class C2 extends B implements IA, IB {}
|
||||
|
||||
volatile B o1, o2;
|
||||
|
||||
@Setup
|
||||
public void setup() {
|
||||
o1 = new C1();
|
||||
o2 = new C2();
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
@OperationsPerInvocation(4)
|
||||
public void test(Blackhole bh) {
|
||||
bh.consume(o1 instanceof IA);
|
||||
bh.consume(o2 instanceof IA);
|
||||
bh.consume(o1 instanceof IB);
|
||||
bh.consume(o2 instanceof IB);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue