Skip to content

Instantly share code, notes, and snippets.

@retronym
Last active October 17, 2025 03:17
Show Gist options
  • Save retronym/0f700356a8fe83e0e65c1d2a75d09ec3 to your computer and use it in GitHub Desktop.
Save retronym/0f700356a8fe83e0e65c1d2a75d09ec3 to your computer and use it in GitHub Desktop.
Cake Pattern checkcast benchmark 2
+---------+------------+------------+-----------+-----------------------------------------------+
| Threads | SupersTable| SupersCache| Avg ns/op | Dominant Hot Methods |
+---------+------------+------------+-----------+-----------------------------------------------+
| 1 | + | + | 6.382 | lookup_secondary_supers_table_slow_path (~65%), Name.outer, measure |
| 1 | - | + | 2.718 | measure, Name.outer, Name.<init> |
| 1 | - | - | 4.186 | measure, Name.outer, Name.<init> |
| 4 | + | + | 7.767 | lookup_secondary_supers_table_slow_path (~64%), Name.outer, Type.outer |
| 4 | - | + | 3.343 | Type.outer, Name.outer, Name.<init> |
| 4 | - | - | 5.641 | Blackhole.consume, Name.<init>, Name.outer |
+---------+------------+------------+-----------+-----------------------------------------------+
package scala.tools.nsc;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import java.lang.reflect.Proxy;
import java.util.*;
import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Thread)
@Warmup(iterations = 4, time = 2)
@Measurement(iterations = 4, time = 2)
@Fork(value = 3)
@Threads(4)
public class CakePattern {
// Approximation of the "Cake Pattern"
static class API {
interface Cake extends Names, Types {}
interface Names {
class Name {
final Names outer;
Name(Names outer) {
this.outer = outer;
}
}
}
interface Types {
class Type {
final Types outer;
Type(Types outer) {
this.outer = outer;
}
}
}
}
static class Impl {
interface Cake extends API.Cake, Names, Types {}
interface Names extends API.Names {
class Name extends API.Names.Name {
// Scala compiler synthetically adds this outer parameter to this constructor and super call.
// As such, it knows that the checkcast below is always successful (modulo null).
Name(Names outer) {
super(outer);
}
Names outer() {
return (Names) this.outer;
}
}
}
interface Types extends API.Types {
class Type extends API.Types.Type {
Type(Types outer) {
super(outer);
}
Types outer() {
return (Types) this.outer;
}
}
}
}
// approximation of scala.tools.nsc.Global (core class in the Scala 2 compiler)
static Impl.Cake global(int numInterfaces) {
Objects.checkIndex(numInterfaces - 1, INTERFACES.length);
// randomly select interfaces to cache-bust speculative compilation schemes of HotSpot.
List<Class<?>> shuffled = new ArrayList<>(Arrays.asList(INTERFACES));
Collections.shuffle(shuffled, new Random());
List<Class<?>> l1 = new ArrayList<>(shuffled.subList(0, numInterfaces));
// last in the list for the worst case linear search
l1.add(Impl.Cake.class);
Class<?>[] interfaces = l1.toArray(Class[]::new);
ClassLoader loader = CakePattern.class.getClassLoader();
return (Impl.Cake) Proxy.newProxyInstance(loader, interfaces, (proxy, _, args) -> null);
}
private Impl.Cake cake;
@Param("80")
public int numInterfaces;
@Setup(Level.Iteration)
public void setup() {
cake = global(numInterfaces);
}
@Benchmark
public Object measure(Blackhole bh) {
// Test against more than one interface to cache-bust the single-element cache in the legacy
// JVM secondary super implementation.
bh.consume(new Impl.Types.Type(cake).outer());
return new Impl.Names.Name(cake).outer();
}
// @formatter:off
static final Class<?>[] INTERFACES = {
I1.class, I2.class, I3.class, I4.class, I5.class, I6.class, I7.class, I8.class, I9.class, I10.class, I11.class, I12.class, I13.class, I14.class, I15.class, I16.class, I17.class, I18.class, I19.class, I20.class, I21.class, I22.class, I23.class, I24.class, I25.class, I26.class, I27.class, I28.class, I29.class, I30.class, I31.class, I32.class, I33.class, I34.class, I35.class, I36.class, I37.class, I38.class, I39.class, I40.class, I41.class, I42.class, I43.class, I44.class, I45.class, I46.class, I47.class, I48.class, I49.class, I50.class, I51.class, I52.class, I53.class, I54.class, I55.class, I56.class, I57.class, I58.class, I59.class, I60.class, I61.class, I62.class, I63.class, I64.class, I65.class, I66.class, I67.class, I68.class, I69.class, I70.class, I71.class, I72.class, I73.class, I74.class, I75.class, I76.class, I77.class, I78.class, I79.class, I80.class, I81.class, I82.class, I83.class, I84.class, I85.class, I86.class, I87.class, I88.class, I89.class, I90.class, I91.class, I92.class, I93.class, I94.class, I95.class, I96.class, I97.class, I98.class, I99.class, I100.class, I101.class, I102.class, I103.class, I104.class, I105.class, I106.class, I107.class, I108.class, I109.class, I110.class, I111.class, I112.class, I113.class, I114.class, I115.class, I116.class, I117.class, I118.class, I119.class, I120.class, I121.class, I122.class, I123.class, I124.class, I125.class, I126.class, I127.class, I128.class, I129.class, I130.class, I131.class, I132.class, I133.class, I134.class, I135.class, I136.class, I137.class, I138.class, I139.class, I140.class, I141.class, I142.class, I143.class, I144.class, I145.class, I146.class, I147.class, I148.class, I149.class, I150.class, I151.class, I152.class, I153.class, I154.class, I155.class, I156.class, I157.class, I158.class, I159.class, I160.class, I161.class, I162.class, I163.class, I164.class, I165.class, I166.class, I167.class, I168.class, I169.class, I170.class, I171.class, I172.class, I173.class, I174.class, I175.class, I176.class, I177.class, I178.class, I179.class, I180.class, I181.class, I182.class, I183.class, I184.class, I185.class, I186.class, I187.class, I188.class, I189.class, I190.class, I191.class, I192.class, I193.class, I194.class, I195.class, I196.class, I197.class, I198.class, I199.class, I200.class, I201.class, I202.class, I203.class, I204.class, I205.class, I206.class, I207.class, I208.class, I209.class, I210.class, I211.class, I212.class, I213.class, I214.class, I215.class, I216.class, I217.class, I218.class, I219.class, I220.class, I221.class, I222.class, I223.class, I224.class, I225.class, I226.class, I227.class, I228.class, I229.class, I230.class, I231.class, I232.class, I233.class, I234.class, I235.class, I236.class, I237.class, I238.class, I239.class, I240.class, I241.class, I242.class, I243.class, I244.class, I245.class, I246.class, I247.class, I248.class, I249.class, I250.class, I251.class, I252.class, I253.class, I254.class, I255.class, I256.class, I257.class, I258.class, I259.class, I260.class, I261.class, I262.class, I263.class, I264.class, I265.class, I266.class, I267.class, I268.class, I269.class, I270.class, I271.class, I272.class, I273.class, I274.class, I275.class, I276.class, I277.class, I278.class, I279.class, I280.class, I281.class, I282.class, I283.class, I284.class, I285.class, I286.class, I287.class, I288.class, I289.class, I290.class, I291.class, I292.class, I293.class, I294.class, I295.class, I296.class, I297.class, I298.class, I299.class, I300.class
};
interface I1 {}; interface I2 {}; interface I3 { }; interface I4 { }; interface I5 { }; interface I6 { }; interface I7 { }; interface I8 { }; interface I9 { }; interface I10 { }; interface I11 { }; interface I12 { }; interface I13 { }; interface I14 { }; interface I15 { }; interface I16 { }; interface I17 { }; interface I18 { }; interface I19 { }; interface I20 { }; interface I21 { }; interface I22 { }; interface I23 { }; interface I24 { }; interface I25 { }; interface I26 { }; interface I27 { }; interface I28 { }; interface I29 { }; interface I30 { }; interface I31 { }; interface I32 { }; interface I33 { }; interface I34 { }; interface I35 { }; interface I36 { }; interface I37 { }; interface I38 { }; interface I39 { }; interface I40 { }; interface I41 { }; interface I42 { }; interface I43 { }; interface I44 { }; interface I45 { }; interface I46 { }; interface I47 { }; interface I48 { }; interface I49 { }; interface I50 { }; interface I51 { }; interface I52 { }; interface I53 { }; interface I54 { }; interface I55 { }; interface I56 { }; interface I57 { }; interface I58 { }; interface I59 { }; interface I60 { }; interface I61 { }; interface I62 { }; interface I63 { }; interface I64 { }; interface I65 { }; interface I66 { }; interface I67 { }; interface I68 { }; interface I69 { }; interface I70 { }; interface I71 { }; interface I72 { }; interface I73 { }; interface I74 { }; interface I75 { }; interface I76 { }; interface I77 { }; interface I78 { }; interface I79 { }; interface I80 { }; interface I81 { }; interface I82 { }; interface I83 { }; interface I84 { }; interface I85 { }; interface I86 { }; interface I87 { }; interface I88 { }; interface I89 { }; interface I90 { }; interface I91 { }; interface I92 { }; interface I93 { }; interface I94 { }; interface I95 { }; interface I96 { }; interface I97 { }; interface I98 { }; interface I99 { }; interface I100 { }; interface I101 { }; interface I102 { }; interface I103 { }; interface I104 { }; interface I105 { }; interface I106 { }; interface I107 { }; interface I108 { }; interface I109 { }; interface I110 { }; interface I111 { }; interface I112 { }; interface I113 { }; interface I114 { }; interface I115 { }; interface I116 { }; interface I117 { }; interface I118 { }; interface I119 { }; interface I120 { }; interface I121 { }; interface I122 { }; interface I123 { }; interface I124 { }; interface I125 { }; interface I126 { }; interface I127 { }; interface I128 { }; interface I129 { }; interface I130 { }; interface I131 { }; interface I132 { }; interface I133 { }; interface I134 { }; interface I135 { }; interface I136 { }; interface I137 { }; interface I138 { }; interface I139 { }; interface I140 { }; interface I141 { }; interface I142 { }; interface I143 { }; interface I144 { }; interface I145 { }; interface I146 { }; interface I147 { }; interface I148 { }; interface I149 { }; interface I150 { }; interface I151 { }; interface I152 { }; interface I153 { }; interface I154 { }; interface I155 { }; interface I156 { }; interface I157 { }; interface I158 { }; interface I159 { }; interface I160 { }; interface I161 { }; interface I162 { }; interface I163 { }; interface I164 { }; interface I165 { }; interface I166 { }; interface I167 { }; interface I168 { }; interface I169 { }; interface I170 { }; interface I171 { }; interface I172 { }; interface I173 { }; interface I174 { }; interface I175 { }; interface I176 { }; interface I177 { }; interface I178 { }; interface I179 { }; interface I180 { }; interface I181 { }; interface I182 { }; interface I183 { }; interface I184 { }; interface I185 { }; interface I186 { }; interface I187 { }; interface I188 { }; interface I189 { }; interface I190 { }; interface I191 { }; interface I192 { }; interface I193 { }; interface I194 { }; interface I195 { }; interface I196 { }; interface I197 { }; interface I198 { }; interface I199 { }; interface I200 { }; interface I201 { }; interface I202 { }; interface I203 { }; interface I204 { }; interface I205 { }; interface I206 { }; interface I207 { }; interface I208 { }; interface I209 { }; interface I210 { }; interface I211 { }; interface I212 { }; interface I213 { }; interface I214 { }; interface I215 { }; interface I216 { }; interface I217 { }; interface I218 { }; interface I219 { }; interface I220 { }; interface I221 { }; interface I222 { }; interface I223 { }; interface I224 { }; interface I225 { }; interface I226 { }; interface I227 { }; interface I228 { }; interface I229 { }; interface I230 { }; interface I231 { }; interface I232 { }; interface I233 { }; interface I234 { }; interface I235 { }; interface I236 { }; interface I237 { }; interface I238 { }; interface I239 { }; interface I240 { }; interface I241 { }; interface I242 { }; interface I243 { }; interface I244 { }; interface I245 { }; interface I246 { }; interface I247 { }; interface I248 { }; interface I249 { }; interface I250 { }; interface I251 { }; interface I252 { }; interface I253 { }; interface I254 { }; interface I255 { }; interface I256 { }; interface I257 { }; interface I258 { }; interface I259 { }; interface I260 { }; interface I261 { }; interface I262 { }; interface I263 { }; interface I264 { }; interface I265 { }; interface I266 { }; interface I267 { }; interface I268 { }; interface I269 { }; interface I270 { }; interface I271 { }; interface I272 { }; interface I273 { }; interface I274 { }; interface I275 { }; interface I276 { }; interface I277 { }; interface I278 { }; interface I279 { }; interface I280 { }; interface I281 { }; interface I282 { }; interface I283 { }; interface I284 { }; interface I285 { }; interface I286 { }; interface I287 { }; interface I288 { }; interface I289 { }; interface I290 { }; interface I291 { }; interface I292 { }; interface I293 { }; interface I294 { }; interface I295 { }; interface I296 { }; interface I297 { }; interface I298 { }; interface I299 { }; interface I300 { };
// @formatter:on
}
/* +UseSecondarySupersTable
[info] ns percent samples top
[info] ---------- ------- ------- ---
[info] 20790000000 64.89% 2079 lookup_secondary_supers_table_slow_path
[info] 4070000000 12.70% 407 scala.tools.nsc.CakePattern$Impl$Types$Type.outer
[info] 3610000000 11.27% 361 scala.tools.nsc.CakePattern$Impl$Names$Name.outer
[info] 2460000000 7.68% 246 org.openjdk.jmh.infra.Blackhole.consume
[info] 1020000000 3.18% 102 scala.tools.nsc.jmh_generated.CakePattern_measure_jmhTest.measure_avgt_jmhStub
[info] 50000000 0.16% 5 scala.tools.nsc.CakePattern$Impl$Types$Type.<init>
[info] Benchmark (numInterfaces) Mode Cnt Score Error Units
[info] CakePattern.measure 80 avgt 12 7.985 ± 0.659 ns/op
[info] CakePattern.measure:async 80 avgt NaN
*/
/* -UseSecondarySupersTable
[info] ns percent samples top
[info] ---------- ------- ------- ---
[info] 12180000000 37.99% 1218 scala.tools.nsc.CakePattern$Impl$Names$Name.outer
[info] 12050000000 37.59% 1205 scala.tools.nsc.CakePattern$Impl$Types$Type.outer
[info] 6150000000 19.18% 615 org.openjdk.jmh.infra.Blackhole.consume
[info] 1400000000 4.37% 140 scala.tools.nsc.jmh_generated.CakePattern_measure_jmhTest.measure_avgt_jmhStub
[info] 110000000 0.34% 11 scala.tools.nsc.CakePattern$Impl$Names$Name.<init>
[info] 70000000 0.22% 7 scala.tools.nsc.CakePattern$Impl$Types$Type.<init>
[info] Benchmark (numInterfaces) Mode Cnt Score Error Units
[info] CakePattern.measure 80 avgt 12 3.021 ± 0.189 ns/op
[info] CakePattern.measure:async 80 avgt NaN ---
[success] Total time: 50 s, completed 17 Oct 2025, 9:31:53 am
*/
[info] # VM version: JDK 25, OpenJDK 64-Bit Server VM, 25+36-LTS
[info] # VM invoker: /Users/jz/.sdkman/candidates/java/25-zulu/zulu-25.jdk/Contents/Home/bin/java
[info] # VM options: -DscalaVersion=2.13.16 -DscalaRef=v2.13.16 -Dsbt.launcher=/opt/homebrew/Cellar/sbt/1.11.0/libexec/bin/sbt-launch.jar -XX:+UnlockDiagnosticVMOptions -XX:+UseSecondarySupersTable -XX:+UseSecondarySupersCache
[info] # Run progress: 0.00% complete, ETA 00:00:48
[info] # Run progress: 33.33% complete, ETA 00:00:32
[info] # Run progress: 66.67% complete, ETA 00:00:16
[info] ns percent samples top
[info] 5340000000 66.42% 534 lookup_secondary_supers_table_slow_path
[info] 1160000000 14.43% 116 scala.tools.nsc.CakePattern.measure
[info] 1030000000 12.81% 103 scala.tools.nsc.CakePattern$Impl$Names$Name.outer
[info] 290000000 3.61% 29 scala.tools.nsc.CakePattern$Impl$Names$Name.<init>
[info] 190000000 2.36% 19 scala.tools.nsc.jmh_generated.CakePattern_measure_jmhTest.measure_avgt_jmhStub
[info] 10000000 0.12% 1 __gettimeofday
[info] 10000000 0.12% 1 java.util.concurrent.ThreadPoolExecutor.workerCountOf
[info] 10000000 0.12% 1 pthread_jit_write_protect_np
[info] ns percent samples top
[info] 5210000000 64.80% 521 lookup_secondary_supers_table_slow_path
[info] 1190000000 14.80% 119 scala.tools.nsc.CakePattern.measure
[info] 1070000000 13.31% 107 scala.tools.nsc.CakePattern$Impl$Names$Name.outer
[info] 320000000 3.98% 32 scala.tools.nsc.CakePattern$Impl$Names$Name.<init>
[info] 220000000 2.74% 22 scala.tools.nsc.jmh_generated.CakePattern_measure_jmhTest.measure_avgt_jmhStub
[info] 10000000 0.12% 1 __psynch_cvwait
[info] 10000000 0.12% 1 java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire
[info] 10000000 0.12% 1 java.util.concurrent.locks.AbstractQueuedSynchronizer.release
[info] ns percent samples top
[info] 5350000000 66.54% 535 lookup_secondary_supers_table_slow_path
[info] 1150000000 14.30% 115 scala.tools.nsc.CakePattern.measure
[info] 920000000 11.44% 92 scala.tools.nsc.CakePattern$Impl$Names$Name.outer
[info] 310000000 3.86% 31 scala.tools.nsc.jmh_generated.CakePattern_measure_jmhTest.measure_avgt_jmhStub
[info] 290000000 3.61% 29 scala.tools.nsc.CakePattern$Impl$Names$Name.<init>
[info] 10000000 0.12% 1 java.util.concurrent.locks.AbstractQueuedSynchronizer$Node.setPrevRelaxed
[info] 10000000 0.12% 1 jdk.internal.misc.Unsafe.putReferenceOpaque
[info] Benchmark (numInterfaces) Mode Cnt Score Error Units
[info] CakePattern.measure 80 avgt 12 6.382 ± 0.468 ns/op
[info] CakePattern.measure:async 80 avgt NaN ---
[info] # VM version: JDK 25, OpenJDK 64-Bit Server VM, 25+36-LTS
[info] # VM invoker: /Users/jz/.sdkman/candidates/java/25-zulu/zulu-25.jdk/Contents/Home/bin/java
[info] # VM options: -DscalaVersion=2.13.16 -DscalaRef=v2.13.16 -Dsbt.launcher=/opt/homebrew/Cellar/sbt/1.11.0/libexec/bin/sbt-launch.jar -XX:+UnlockDiagnosticVMOptions -XX:-UseSecondarySupersTable -XX:+UseSecondarySupersCache
[info] # Run progress: 0.00% complete, ETA 00:00:48
[info] # Run progress: 33.33% complete, ETA 00:00:32
[info] # Run progress: 66.67% complete, ETA 00:00:16
[info] ns percent samples top
[info] 4210000000 52.36% 421 scala.tools.nsc.CakePattern.measure
[info] 3020000000 37.56% 302 scala.tools.nsc.CakePattern$Impl$Names$Name.outer
[info] 460000000 5.72% 46 scala.tools.nsc.jmh_generated.CakePattern_measure_jmhTest.measure_avgt_jmhStub
[info] 330000000 4.10% 33 scala.tools.nsc.CakePattern$Impl$Names$Name.<init>
[info] 10000000 0.12% 1 jdk.internal.misc.Unsafe.park
[info] 10000000 0.12% 1 scala.tools.nsc.jmh_generated.CakePattern_measure_jmhTest.measure_AverageTime
[info] ns percent samples top
[info] 4100000000 51.19% 410 scala.tools.nsc.CakePattern.measure
[info] 2980000000 37.20% 298 scala.tools.nsc.CakePattern$Impl$Names$Name.outer
[info] 520000000 6.49% 52 scala.tools.nsc.jmh_generated.CakePattern_measure_jmhTest.measure_avgt_jmhStub
[info] 400000000 4.99% 40 scala.tools.nsc.CakePattern$Impl$Names$Name.<init>
[info] 10000000 0.12% 1 pthread_jit_write_protect_np
[info] ns percent samples top
[info] 3880000000 48.32% 388 scala.tools.nsc.CakePattern.measure
[info] 3200000000 39.85% 320 scala.tools.nsc.CakePattern$Impl$Names$Name.outer
[info] 560000000 6.97% 56 scala.tools.nsc.jmh_generated.CakePattern_measure_jmhTest.measure_avgt_jmhStub
[info] 370000000 4.61% 37 scala.tools.nsc.CakePattern$Impl$Names$Name.<init>
[info] 20000000 0.25% 2 __psynch_cvwait
[info] Benchmark (numInterfaces) Mode Cnt Score Error Units
[info] CakePattern.measure 80 avgt 12 2.718 ± 0.075 ns/op
[info] CakePattern.measure:async 80 avgt NaN ---
[info] # VM version: JDK 25, OpenJDK 64-Bit Server VM, 25+36-LTS
[info] # VM invoker: /Users/jz/.sdkman/candidates/java/25-zulu/zulu-25.jdk/Contents/Home/bin/java
[info] # VM options: -DscalaVersion=2.13.16 -DscalaRef=v2.13.16 -Dsbt.launcher=/opt/homebrew/Cellar/sbt/1.11.0/libexec/bin/sbt-launch.jar -XX:+UnlockDiagnosticVMOptions -XX:-UseSecondarySupersTable -XX:-UseSecondarySupersCache
[info] # Run progress: 0.00% complete, ETA 00:00:48
[info] # Run progress: 33.33% complete, ETA 00:00:32
[info] # Run progress: 66.67% complete, ETA 00:00:16
[info] ns percent samples top
[info] 4260000000 52.99% 426 scala.tools.nsc.CakePattern.measure
[info] 3120000000 38.81% 312 scala.tools.nsc.CakePattern$Impl$Names$Name.outer
[info] 340000000 4.23% 34 scala.tools.nsc.CakePattern$Impl$Names$Name.<init>
[info] 300000000 3.73% 30 scala.tools.nsc.jmh_generated.CakePattern_measure_jmhTest.measure_avgt_jmhStub
[info] 10000000 0.12% 1 Unsafe_CompareAndSetInt
[info] 10000000 0.12% 1 __psynch_cvwait
[info] ns percent samples top
[info] 4000000000 49.81% 400 scala.tools.nsc.CakePattern.measure
[info] 3350000000 41.72% 335 scala.tools.nsc.CakePattern$Impl$Names$Name.outer
[info] 380000000 4.73% 38 scala.tools.nsc.CakePattern$Impl$Names$Name.<init>
[info] 280000000 3.49% 28 scala.tools.nsc.jmh_generated.CakePattern_measure_jmhTest.measure_avgt_jmhStub
[info] 10000000 0.12% 1 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos
[info] 10000000 0.12% 1 java.util.concurrent.locks.ReentrantLock$Sync.tryRelease
[info] ns percent samples top
[info] 4280000000 53.10% 428 scala.tools.nsc.CakePattern.measure
[info] 3160000000 39.21% 316 scala.tools.nsc.CakePattern$Impl$Names$Name.outer
[info] 320000000 3.97% 32 scala.tools.nsc.CakePattern$Impl$Names$Name.<init>
[info] 250000000 3.10% 25 scala.tools.nsc.jmh_generated.CakePattern_measure_jmhTest.measure_avgt_jmhStub
[info] 20000000 0.25% 2 __psynch_cvwait
[info] 20000000 0.25% 2 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos
[info] 10000000 0.12% 1 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.signal
[info] Benchmark (numInterfaces) Mode Cnt Score Error Units
[info] CakePattern.measure 80 avgt 12 4.186 ± 0.201 ns/op
[info] CakePattern.measure:async 80 avgt NaN
[info] # VM version: JDK 25, OpenJDK 64-Bit Server VM, 25+36-LTS
[info] # VM invoker: /Users/jz/.sdkman/candidates/java/25-zulu/zulu-25.jdk/Contents/Home/bin/java
[info] # VM options: -DscalaVersion=2.13.16 -DscalaRef=v2.13.16 -Dsbt.launcher=/opt/homebrew/Cellar/sbt/1.11.0/libexec/bin/sbt-launch.jar -XX:+UnlockDiagnosticVMOptions -XX:+UseSecondarySupersTable -XX:+UseSecondarySupersCache
[info] # Run progress: 0.00% complete, ETA 00:00:48
[info] # Run progress: 33.33% complete, ETA 00:00:32
[info] # Run progress: 66.67% complete, ETA 00:00:16
[info] ns percent samples top
[info] 21180000000 65.92% 2118 lookup_secondary_supers_table_slow_path
[info] 4430000000 13.79% 443 scala.tools.nsc.CakePattern$Impl$Names$Name.outer
[info] 2670000000 8.31% 267 scala.tools.nsc.CakePattern$Impl$Types$Type.outer
[info] 2420000000 7.53% 242 scala.tools.nsc.CakePattern$Impl$Names$Name.<init>
[info] 1200000000 3.73% 120 scala.tools.nsc.jmh_generated.CakePattern_measure_jmhTest.measure_avgt_jmhStub
[info] 130000000 0.40% 13 scala.tools.nsc.CakePattern$Impl$Types$Type.<init>
[info] 20000000 0.06% 2 __psynch_mutexwait
[info] 10000000 0.03% 1 BlockListBuilder::BlockListBuilder
[info] 10000000 0.03% 1 CallStaticJavaNode::Opcode
[info] 10000000 0.03% 1 JavaThread::pd_last_frame
[info] 10000000 0.03% 1 MethodMatcher::matches
[info] 10000000 0.03% 1 PhaseIFG::SquareUp
[info] 10000000 0.03% 1 Unsafe_Park
[info] 10000000 0.03% 1 __psynch_cvsignal
[info] 10000000 0.03% 1 _platform_memset
[info] ns percent samples top
[info] 20680000000 64.34% 2068 lookup_secondary_supers_table_slow_path
[info] 4070000000 12.66% 407 scala.tools.nsc.CakePattern$Impl$Names$Name.outer
[info] 3760000000 11.70% 376 scala.tools.nsc.CakePattern$Impl$Types$Type.outer
[info] 2440000000 7.59% 244 org.openjdk.jmh.infra.Blackhole.consume
[info] 940000000 2.92% 94 scala.tools.nsc.jmh_generated.CakePattern_measure_jmhTest.measure_avgt_jmhStub
[info] 110000000 0.34% 11 scala.tools.nsc.CakePattern$Impl$Types$Type.<init>
[info] 20000000 0.06% 2 __psynch_mutexwait
[info] 10000000 0.03% 1 ClassFileParser::verify_legal_field_name
[info] 10000000 0.03% 1 KlassFactory::create_from_stream
[info] 10000000 0.03% 1 Node_Array::at
[info] 10000000 0.03% 1 PhaseChaitin::build_ifg_physical
[info] 10000000 0.03% 1 ValueStack::values_do
[info] 10000000 0.03% 1 __psynch_cvwait
[info] 10000000 0.03% 1 java.lang.String.replace
[info] 10000000 0.03% 1 java.lang.Thread.isVirtual
[info] 10000000 0.03% 1 java.util.concurrent.LinkedBlockingQueue.offer
[info] 10000000 0.03% 1 jdk.internal.classfile.impl.AbstractPoolEntry$NameAndTypeEntryImpl.type
[info] 10000000 0.03% 1 jdk.internal.classfile.impl.StackMapDecoder.writeFrames
[info] 10000000 0.03% 1 pthread_mutex_lock
[info] ns percent samples top
[info] 20620000000 64.20% 2062 lookup_secondary_supers_table_slow_path
[info] 4420000000 13.76% 442 scala.tools.nsc.CakePattern$Impl$Names$Name.outer
[info] 3980000000 12.39% 398 scala.tools.nsc.CakePattern$Impl$Types$Type.outer
[info] 2200000000 6.85% 220 org.openjdk.jmh.infra.Blackhole.consume
[info] 820000000 2.55% 82 scala.tools.nsc.jmh_generated.CakePattern_measure_jmhTest.measure_avgt_jmhStub
[info] 40000000 0.12% 4 scala.tools.nsc.CakePattern$Impl$Types$Type.<init>
[info] 10000000 0.03% 1 AccessField::input_values_do
[info] 10000000 0.03% 1 PhaseLive::compute
[info] 10000000 0.03% 1 java.lang.invoke.VarHandleGuards.guard_LLL_Z
[info] 10000000 0.03% 1 pthread_mutex_unlock
[info] Benchmark (numInterfaces) Mode Cnt Score Error Units
[info] CakePattern.measure 80 avgt 12 7.767 ± 0.838 ns/op
[info] CakePattern.measure:async 80 avgt NaN ---
[info] # VM version: JDK 25, OpenJDK 64-Bit Server VM, 25+36-LTS
[info] # VM invoker: /Users/jz/.sdkman/candidates/java/25-zulu/zulu-25.jdk/Contents/Home/bin/java
[info] # VM options: -DscalaVersion=2.13.16 -DscalaRef=v2.13.16 -Dsbt.launcher=/opt/homebrew/Cellar/sbt/1.11.0/libexec/bin/sbt-launch.jar -XX:+UnlockDiagnosticVMOptions -XX:-UseSecondarySupersTable -XX:+UseSecondarySupersCache
[info] # Run progress: 0.00% complete, ETA 00:00:48
[info] # Run progress: 33.33% complete, ETA 00:00:32
[info] # Run progress: 66.67% complete, ETA 00:00:16
[info] ns percent samples top
[info] 16670000000 51.92% 1667 scala.tools.nsc.CakePattern$Impl$Types$Type.outer
[info] 10890000000 33.91% 1089 scala.tools.nsc.CakePattern$Impl$Names$Name.outer
[info] 2390000000 7.44% 239 scala.tools.nsc.jmh_generated.CakePattern_measure_jmhTest.measure_avgt_jmhStub
[info] 1950000000 6.07% 195 org.openjdk.jmh.infra.Blackhole.consume
[info] 180000000 0.56% 18 scala.tools.nsc.CakePattern$Impl$Types$Type.<init>
[info] 10000000 0.03% 1 GrowableArrayWithAllocator<LIR_Op*, GrowableArray<LIR_Op*>>::expand_to
[info] 10000000 0.03% 1 java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire
[info] 10000000 0.03% 1 java.util.concurrent.locks.ReentrantLock$Sync.isHeldExclusively
[info] ns percent samples top
[info] 13580000000 42.25% 1358 scala.tools.nsc.CakePattern$Impl$Names$Name.outer
[info] 12430000000 38.67% 1243 scala.tools.nsc.CakePattern$Impl$Types$Type.outer
[info] 4300000000 13.38% 430 scala.tools.nsc.CakePattern$Impl$Names$Name.<init>
[info] 1630000000 5.07% 163 scala.tools.nsc.jmh_generated.CakePattern_measure_jmhTest.measure_avgt_jmhStub
[info] 140000000 0.44% 14 scala.tools.nsc.CakePattern$Impl$Types$Type.<init>
[info] 10000000 0.03% 1 Klass::is_subclass_of
[info] 10000000 0.03% 1 LinearScanWalker::alloc_free_reg
[info] 10000000 0.03% 1 PhiResolver::create_node
[info] 10000000 0.03% 1 __psynch_cvsignal
[info] 10000000 0.03% 1 __psynch_cvwait
[info] 10000000 0.03% 1 java.util.concurrent.locks.ReentrantLock$Sync.tryRelease
[info] ns percent samples top
[info] 13210000000 42.04% 1321 scala.tools.nsc.CakePattern$Impl$Names$Name.outer
[info] 12700000000 40.42% 1270 scala.tools.nsc.CakePattern$Impl$Types$Type.outer
[info] 4080000000 12.99% 408 scala.tools.nsc.CakePattern$Impl$Names$Name.<init>
[info] 1230000000 3.91% 123 scala.tools.nsc.jmh_generated.CakePattern_measure_jmhTest.measure_avgt_jmhStub
[info] 70000000 0.22% 7 scala.tools.nsc.CakePattern$Impl$Types$Type.<init>
[info] 30000000 0.10% 3 __psynch_cvwait
[info] 10000000 0.03% 1 MacroAssembler::addptr
[info] 10000000 0.03% 1 PhaseIterGVN::transform_old
[info] 10000000 0.03% 1 SymbolTable::lookup_shared
[info] 10000000 0.03% 1 VerificationType::resolve_and_check_assignability
[info] 10000000 0.03% 1 __psynch_cvsignal
[info] 10000000 0.03% 1 __psynch_mutexdrop
[info] 10000000 0.03% 1 __psynch_mutexwait
[info] 10000000 0.03% 1 java.lang.invoke.VarHandleGuards.guard_LII_Z
[info] 10000000 0.03% 1 java.lang.invoke.VarHandleReferences$FieldInstanceReadWrite.compareAndSet
[info] 10000000 0.03% 1 scala.tools.nsc.jmh_generated.CakePattern_measure_jmhTest.measure_AverageTime
[info] Benchmark (numInterfaces) Mode Cnt Score Error Units
[info] CakePattern.measure 80 avgt 12 3.343 ± 0.121 ns/op
[info] CakePattern.measure:async 80 avgt NaN ---
[info] # VM version: JDK 25, OpenJDK 64-Bit Server VM, 25+36-LTS
[info] # VM invoker: /Users/jz/.sdkman/candidates/java/25-zulu/zulu-25.jdk/Contents/Home/bin/java
[info] # VM options: -DscalaVersion=2.13.16 -DscalaRef=v2.13.16 -Dsbt.launcher=/opt/homebrew/Cellar/sbt/1.11.0/libexec/bin/sbt-launch.jar -XX:+UnlockDiagnosticVMOptions -XX:-UseSecondarySupersTable -XX:-UseSecondarySupersCache
[info] # Run progress: 0.00% complete, ETA 00:00:48
[info] # Run progress: 33.33% complete, ETA 00:00:33
[info] # Run progress: 66.67% complete, ETA 00:00:16
[info] ns percent samples top
[info] 17440000000 54.89% 1744 scala.tools.nsc.CakePattern$Impl$Names$Name.<init>
[info] 12930000000 40.70% 1293 scala.tools.nsc.CakePattern$Impl$Names$Name.outer
[info] 1230000000 3.87% 123 scala.tools.nsc.jmh_generated.CakePattern_measure_jmhTest.measure_avgt_jmhStub
[info] 90000000 0.28% 9 scala.tools.nsc.CakePattern$Impl$Types$Type.<init>
[info] 30000000 0.09% 3 __psynch_cvwait
[info] 10000000 0.03% 1 CodeHeap::allocate
[info] 10000000 0.03% 1 CompilationPolicy::is_old
[info] 10000000 0.03% 1 PhaseChaitin::get_spillcopy_wide
[info] 10000000 0.03% 1 java.util.Objects.requireNonNull
[info] 10000000 0.03% 1 java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire
[info] ns percent samples top
[info] 15350000000 47.80% 1535 org.openjdk.jmh.infra.Blackhole.consume
[info] 14850000000 46.25% 1485 scala.tools.nsc.CakePattern$Impl$Names$Name.<init>
[info] 1720000000 5.36% 172 scala.tools.nsc.jmh_generated.CakePattern_measure_jmhTest.measure_avgt_jmhStub
[info] 60000000 0.19% 6 scala.tools.nsc.CakePattern$Impl$Types$Type.<init>
[info] 40000000 0.12% 4 __psynch_mutexwait
[info] 10000000 0.03% 1 Matcher::xform
[info] 10000000 0.03% 1 MemAllocator::allocate
[info] 10000000 0.03% 1 Node::Identity
[info] 10000000 0.03% 1 PhaseChaitin::post_allocate_copy_removal
[info] 10000000 0.03% 1 __psynch_cvwait
[info] 10000000 0.03% 1 __psynch_mutexdrop
[info] 10000000 0.03% 1 ciExceptionHandlerStream::next
[info] 10000000 0.03% 1 java.util.concurrent.ThreadPoolExecutor.isRunning
[info] 10000000 0.03% 1 jdk.internal.misc.Unsafe.putReferenceVolatile
[info] ns percent samples top
[info] 15440000000 48.02% 1544 org.openjdk.jmh.infra.Blackhole.consume
[info] 14770000000 45.94% 1477 scala.tools.nsc.CakePattern$Impl$Names$Name.<init>
[info] 1740000000 5.41% 174 scala.tools.nsc.jmh_generated.CakePattern_measure_jmhTest.measure_avgt_jmhStub
[info] 60000000 0.19% 6 scala.tools.nsc.CakePattern$Impl$Types$Type.<init>
[info] 20000000 0.06% 2 __psynch_cvwait
[info] 20000000 0.06% 2 scala.tools.nsc.CakePattern$Impl$Types$Type.outer
[info] 10000000 0.03% 1 ChunkPool::clean
[info] 10000000 0.03% 1 Matcher::match_tree
[info] 10000000 0.03% 1 Matcher::xform
[info] 10000000 0.03% 1 Node::is_dead_loop_safe
[info] 10000000 0.03% 1 PhaseChaitin::remove_bound_register_from_interfering_live_ranges
[info] 10000000 0.03% 1 PhaseOutput::BuildOopMaps
[info] 10000000 0.03% 1 ValueRecorder<Metadata*>::maybe_initialize
[info] 10000000 0.03% 1 java.util.Arrays.copyOfRange
[info] 10000000 0.03% 1 java.util.concurrent.LinkedBlockingQueue.signalNotEmpty
[info] 10000000 0.03% 1 org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call
[info] Benchmark (numInterfaces) Mode Cnt Score Error Units
[info] CakePattern.measure 80 avgt 12 5.641 ± 0.337 ns/op
[info] CakePattern.measure:async 80 avgt NaN ---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment