Foreign memory access hot loop benchmark

Antoine Chambille ach at activeviam.com
Tue Nov 24 11:19:08 UTC 2020


>> Can you try with longs (instead of doubles) and see what happens?


Hi Maurizio,

Thanks for the idea, I have added a benchmark case with 'long' data
elements instead of 'double'. But this does not appear to be the root
cause, both 'AddBenchmark.unrolledMHI_v2' and
'AddBenchmark.unrolledMHI_v2_long' exhibit the same performance drop.

https://github.com/chamb/panama-benchmarks/blob/master/memory/src/main/java/com/activeviam/test/AddBenchmark.java


Benchmark                            Mode  Cnt        Score         Error
Units
AddBenchmark.scalarArray            thrpt    5  5639324.087 ▒  112374.776
ops/s
AddBenchmark.scalarArrayHandle      thrpt    5  5248835.802 ▒  297162.076
ops/s
AddBenchmark.scalarUnsafe           thrpt    5  2818205.689 ▒   37068.210
ops/s
AddBenchmark.scalarMHI              thrpt    5  3091050.372 ▒   96053.983
ops/s
AddBenchmark.scalarMHI_v2           thrpt    5  2060722.656 ▒  113811.198
ops/s
AddBenchmark.unrolledArray          thrpt    5  8719611.783 ▒  139960.462
ops/s
AddBenchmark.unrolledArrayHandle    thrpt    5  1860633.229 ▒   12637.963
ops/s
AddBenchmark.unrolledUnsafe         thrpt    5  2031815.305 ▒   38125.522
ops/s
AddBenchmark.unrolledMHI            thrpt    5  2868852.729 ▒   76666.950
ops/s
AddBenchmark.unrolledMHI_long       thrpt    5  2067284.013 ▒    9080.000
ops/s
AddBenchmark.unrolledMHI_v2         thrpt    5   112356.958 ▒     926.272
ops/s
AddBenchmark.unrolledMHI_v2_long    thrpt    5   113935.620 ▒    7807.998
ops/s




If I look at the slow benchmark in detail, I observe that the first two
warmups run at the expected speed, but then it slows down 20x. Very
strange, it's almost as if some JIT optimization is suddenly turned off:


# JMH version: 1.25.1
# VM version: JDK 16-internal, OpenJDK 64-Bit Server VM,
16-internal+0-adhoc.achambille.memory
# VM invoker:
D:\openjdk\memory\build\windows-x86_64-server-release\images\jdk\bin\java.exe
# VM options: --add-modules=jdk.incubator.foreign
-Dforeign.restricted=permit
# Warmup: 5 iterations, 10 s each

# Measurement: 5 iterations, 10 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Benchmark: com.activeviam.test.AddBenchmark.unrolledMHI_v2

# Run progress: 0.00% complete, ETA 00:35:00
# Fork: 1 of 1
WARNING: Using incubator modules: jdk.incubator.foreign
# Warmup Iteration   1: 2317170.890 ops/s
# Warmup Iteration   2: 2357170.160 ops/s
# Warmup Iteration   3: 112603.925 ops/s
# Warmup Iteration   4: 112240.534 ops/s
# Warmup Iteration   5: 112749.027 ops/s
Iteration   1: 112171.298 ops/s
Iteration   2: 112452.153 ops/s
Iteration   3: 112569.533 ops/s
Iteration   4: 112555.980 ops/s
Iteration   5: 112035.824 ops/s



-Antoine


More information about the panama-dev mailing list