Unexpected exceptions during benchmark
John Auden
lovedthefaioli at gmail.com
Sat Sep 23 02:03:23 UTC 2023
Hi,
I was trying to create a concurrency benchmark, but noticed that it fails
in a very basic logic block.
*I know that it is a bad idea to run benchmarks inside a VM, but I do it
rather for quick check and because I have debug JDK releases + hsdis there.
This email is not to submit a bug, but rather just for your information.*
Host: 16 cores Azure VM (Intel(R) Xeon(R) CPU E5-2673 v4 @ 2.30GHz)
$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 16
On-line CPU(s) list: 0-15
OS: CentOS Linux release 7.9.2009
JDK: 17.0.5
@Threads(Threads.MAX)
public class HMBenchmark {
private final static Map<Long, Long> map = new
HashMap<>(Runtime.getRuntime().availableProcessors());
@Benchmark
public void testHM() {
Long id = Thread.currentThread().getId();
map.put(id, 0L);
for (long i = 0; i < 100_000; i++) {
map.put(id, map.get(id) + i);
}
}
}
If the number of threads is set above 12 (up to Threads.MAX) this benchmark
starts to fail. WIth 13, 14, 15 it fails with NPE (even though program
order should theoretically protect code against NPE):
*java.lang.NullPointerException: Cannot invoke "java.lang.Long.longValue()"
because the return value of "java.util.Map.get(Object)" is null at
org.ad.HMBenchmark.testHM(HMBenchmark.java:33) at
org.ad.jmh_generated.HMBenchmark_testHM_jmhTest.testHM_Throughput(HMBenchmark_testHM_jmhTest.java:78)*
WIth MAX threads (or 16) there is also this interesting exception:
*java.lang.IllegalStateException: More threads than expected at
org.openjdk.jmh.runner.InfraControlL2.announceWarmupReady(InfraControl.java:222)
at
org.openjdk.jmh.runner.InfraControl.announceWarmupReady(InfraControl.java:40)
at
org.ad.jmh_generated.HMBenchmark_testHM_jmhTest.testHM_Throughput(HMBenchmark_testHM_jmhTest.java:76)*
Regards,
Alex Dubrouski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jmh-dev/attachments/20230922/7c71a7f4/attachment.htm>
More information about the jmh-dev
mailing list