hashmap-concurrenthashmap: companion code for the HashMap vs ConcurrentHashMap interview guide
Adds JMH put/get throughput benchmarks (synchronizedMap vs ConcurrentHashMap, swept at 1/2/4/8 threads), a computeIfAbsent recursion trap demo (CHM tolerates recursion into a different key but throws IllegalStateException on the same key; plain HashMap throws ConcurrentModificationException even single-threaded), and a null-handling demo (CHM rejects null keys/values on put() and null keys on get() too). 7/7 JUnit tests pass; all output/ transcripts captured from real runs. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FhzLY5p6okFva3qsnsRyvM
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
$ java ComputeIfAbsentRecursionDemo
|
||||
|
||||
=== ConcurrentHashMap: computeIfAbsent recursing into a DIFFERENT key ===
|
||||
no exception, result = 99, map = {1=99, 2=99}
|
||||
|
||||
=== HashMap: computeIfAbsent recursing into a DIFFERENT key (single-threaded!) ===
|
||||
threw java.util.ConcurrentModificationException: null
|
||||
|
||||
=== ConcurrentHashMap: computeIfAbsent recursing into the SAME key ===
|
||||
threw java.lang.IllegalStateException: Recursive update
|
||||
@@ -0,0 +1,14 @@
|
||||
$ java NullHandlingDemo
|
||||
|
||||
=== HashMap: null key and null value are both fine ===
|
||||
hm.get(null) = nullKeyValue
|
||||
hm.get("k1") = null
|
||||
|
||||
=== ConcurrentHashMap: null key throws on put() ===
|
||||
chm.put(null, "x") threw NullPointerException
|
||||
|
||||
=== ConcurrentHashMap: null value throws on put() ===
|
||||
chm.put("k1", null) threw NullPointerException
|
||||
|
||||
=== ConcurrentHashMap: get(null) ALSO throws, not just put() ===
|
||||
chm.get(null) threw: Cannot invoke "Object.hashCode()" because "key" is null
|
||||
@@ -0,0 +1,91 @@
|
||||
$ java -jar benchmarks.jar PutGetBenchmark -t 1
|
||||
|
||||
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by org.openjdk.jmh.util.Utils (file:/home/claude/java-core-examples/hashmap-concurrenthashmap/target/benchmarks.jar)
|
||||
WARNING: Please consider reporting this to the maintainers of class org.openjdk.jmh.util.Utils
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
|
||||
# JMH version: 1.37
|
||||
# VM version: JDK 25.0.4.1, OpenJDK 64-Bit Server VM, 25.0.4.1+1-LTS
|
||||
# VM invoker: /tmp/tools/jdk-25.0.4.1+1/bin/java
|
||||
# VM options: -Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts -Djavax.net.ssl.trustStoreType=JKS -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=36265 -Dhttp.nonProxyHosts=localhost|127.0.0.1|::1|127.*|0.*|::|169.254.*|api.anthropic.com|api-staging.anthropic.com|api-pr-preview.anthropic.com|mcp-proxy.anthropic.com|mcp-proxy-staging.anthropic.com|registry.npmjs.org|jsr.io|npm.jsr.io|pypi.org|files.pythonhosted.org|index.crates.io|proxy.golang.org|host.docker.internal|10.*|172.16.*|172.17.*|172.18.*|172.19.*|172.20.*|172.21.*|172.22.*|172.23.*|172.24.*|172.25.*|172.26.*|172.27.*|172.28.*|172.29.*|172.30.*|172.31.*|192.168.*|100.64.0.0/10|*.svc.cluster.local|*.svc.cluster.local -Djdk.http.auth.tunneling.disabledSchemes= -Djdk.http.auth.proxying.disabledSchemes=
|
||||
# Blackhole mode: compiler (auto-detected, use -Djmh.blackhole.autoDetect=false to disable)
|
||||
# Warmup: 3 iterations, 1 s each
|
||||
# Measurement: 5 iterations, 1 s each
|
||||
# Timeout: 10 min per iteration
|
||||
# Threads: 1 thread, will synchronize iterations
|
||||
# Benchmark mode: Throughput, ops/time
|
||||
# Benchmark: com.ankurm.hashmapconcurrenthashmap.PutGetBenchmark.concurrentHashMapPutGet
|
||||
|
||||
# Run progress: 0.00% complete, ETA 00:00:16
|
||||
# Fork: 1 of 1
|
||||
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by org.openjdk.jmh.util.Utils (file:/home/claude/java-core-examples/hashmap-concurrenthashmap/target/benchmarks.jar)
|
||||
WARNING: Please consider reporting this to the maintainers of class org.openjdk.jmh.util.Utils
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
|
||||
# Warmup Iteration 1: 41935.635 ops/ms
|
||||
# Warmup Iteration 2: 34018.409 ops/ms
|
||||
# Warmup Iteration 3: 43093.817 ops/ms
|
||||
Iteration 1: 40152.383 ops/ms
|
||||
Iteration 2: 43889.780 ops/ms
|
||||
Iteration 3: 50954.867 ops/ms
|
||||
Iteration 4: 47590.666 ops/ms
|
||||
Iteration 5: 49160.178 ops/ms
|
||||
|
||||
|
||||
Result "com.ankurm.hashmapconcurrenthashmap.PutGetBenchmark.concurrentHashMapPutGet":
|
||||
46349.575 ±(99.9%) 16685.366 ops/ms [Average]
|
||||
(min, avg, max) = (40152.383, 46349.575, 50954.867), stdev = 4333.136
|
||||
CI (99.9%): [29664.209, 63034.940] (assumes normal distribution)
|
||||
|
||||
|
||||
# JMH version: 1.37
|
||||
# VM version: JDK 25.0.4.1, OpenJDK 64-Bit Server VM, 25.0.4.1+1-LTS
|
||||
# VM invoker: /tmp/tools/jdk-25.0.4.1+1/bin/java
|
||||
# VM options: -Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts -Djavax.net.ssl.trustStoreType=JKS -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=36265 -Dhttp.nonProxyHosts=localhost|127.0.0.1|::1|127.*|0.*|::|169.254.*|api.anthropic.com|api-staging.anthropic.com|api-pr-preview.anthropic.com|mcp-proxy.anthropic.com|mcp-proxy-staging.anthropic.com|registry.npmjs.org|jsr.io|npm.jsr.io|pypi.org|files.pythonhosted.org|index.crates.io|proxy.golang.org|host.docker.internal|10.*|172.16.*|172.17.*|172.18.*|172.19.*|172.20.*|172.21.*|172.22.*|172.23.*|172.24.*|172.25.*|172.26.*|172.27.*|172.28.*|172.29.*|172.30.*|172.31.*|192.168.*|100.64.0.0/10|*.svc.cluster.local|*.svc.cluster.local -Djdk.http.auth.tunneling.disabledSchemes= -Djdk.http.auth.proxying.disabledSchemes=
|
||||
# Blackhole mode: compiler (auto-detected, use -Djmh.blackhole.autoDetect=false to disable)
|
||||
# Warmup: 3 iterations, 1 s each
|
||||
# Measurement: 5 iterations, 1 s each
|
||||
# Timeout: 10 min per iteration
|
||||
# Threads: 1 thread, will synchronize iterations
|
||||
# Benchmark mode: Throughput, ops/time
|
||||
# Benchmark: com.ankurm.hashmapconcurrenthashmap.PutGetBenchmark.synchronizedHashMapPutGet
|
||||
|
||||
# Run progress: 50.00% complete, ETA 00:00:08
|
||||
# Fork: 1 of 1
|
||||
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by org.openjdk.jmh.util.Utils (file:/home/claude/java-core-examples/hashmap-concurrenthashmap/target/benchmarks.jar)
|
||||
WARNING: Please consider reporting this to the maintainers of class org.openjdk.jmh.util.Utils
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
|
||||
# Warmup Iteration 1: 31892.267 ops/ms
|
||||
# Warmup Iteration 2: 31779.124 ops/ms
|
||||
# Warmup Iteration 3: 27890.347 ops/ms
|
||||
Iteration 1: 32671.624 ops/ms
|
||||
Iteration 2: 31503.343 ops/ms
|
||||
Iteration 3: 34632.944 ops/ms
|
||||
Iteration 4: 35160.134 ops/ms
|
||||
Iteration 5: 33405.969 ops/ms
|
||||
|
||||
|
||||
Result "com.ankurm.hashmapconcurrenthashmap.PutGetBenchmark.synchronizedHashMapPutGet":
|
||||
33474.803 ±(99.9%) 5684.794 ops/ms [Average]
|
||||
(min, avg, max) = (31503.343, 33474.803, 35160.134), stdev = 1476.323
|
||||
CI (99.9%): [27790.009, 39159.597] (assumes normal distribution)
|
||||
|
||||
|
||||
# Run complete. Total time: 00:00:16
|
||||
|
||||
REMEMBER: The numbers below are just data. To gain reusable insights, you need to follow up on
|
||||
why the numbers are the way they are. Use profilers (see -prof, -lprof), design factorial
|
||||
experiments, perform baseline and negative tests that provide experimental control, make sure
|
||||
the benchmarking environment is safe on JVM/OS/HW level, ask for reviews from the domain experts.
|
||||
Do not assume the numbers tell you what you want them to tell.
|
||||
|
||||
NOTE: Current JVM experimentally supports Compiler Blackholes, and they are in use. Please exercise
|
||||
extra caution when trusting the results, look into the generated code to check the benchmark still
|
||||
works, and factor in a small probability of new VM bugs. Additionally, while comparisons between
|
||||
different JVMs are already problematic, the performance difference caused by different Blackhole
|
||||
modes can be very significant. Please make sure you use the consistent Blackhole mode for comparisons.
|
||||
|
||||
Benchmark Mode Cnt Score Error Units
|
||||
PutGetBenchmark.concurrentHashMapPutGet thrpt 5 46349.575 ± 16685.366 ops/ms
|
||||
PutGetBenchmark.synchronizedHashMapPutGet thrpt 5 33474.803 ± 5684.794 ops/ms
|
||||
@@ -0,0 +1,91 @@
|
||||
$ java -jar benchmarks.jar PutGetBenchmark -t 2
|
||||
|
||||
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by org.openjdk.jmh.util.Utils (file:/home/claude/java-core-examples/hashmap-concurrenthashmap/target/benchmarks.jar)
|
||||
WARNING: Please consider reporting this to the maintainers of class org.openjdk.jmh.util.Utils
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
|
||||
# JMH version: 1.37
|
||||
# VM version: JDK 25.0.4.1, OpenJDK 64-Bit Server VM, 25.0.4.1+1-LTS
|
||||
# VM invoker: /tmp/tools/jdk-25.0.4.1+1/bin/java
|
||||
# VM options: -Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts -Djavax.net.ssl.trustStoreType=JKS -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=36265 -Dhttp.nonProxyHosts=localhost|127.0.0.1|::1|127.*|0.*|::|169.254.*|api.anthropic.com|api-staging.anthropic.com|api-pr-preview.anthropic.com|mcp-proxy.anthropic.com|mcp-proxy-staging.anthropic.com|registry.npmjs.org|jsr.io|npm.jsr.io|pypi.org|files.pythonhosted.org|index.crates.io|proxy.golang.org|host.docker.internal|10.*|172.16.*|172.17.*|172.18.*|172.19.*|172.20.*|172.21.*|172.22.*|172.23.*|172.24.*|172.25.*|172.26.*|172.27.*|172.28.*|172.29.*|172.30.*|172.31.*|192.168.*|100.64.0.0/10|*.svc.cluster.local|*.svc.cluster.local -Djdk.http.auth.tunneling.disabledSchemes= -Djdk.http.auth.proxying.disabledSchemes=
|
||||
# Blackhole mode: compiler (auto-detected, use -Djmh.blackhole.autoDetect=false to disable)
|
||||
# Warmup: 3 iterations, 1 s each
|
||||
# Measurement: 5 iterations, 1 s each
|
||||
# Timeout: 10 min per iteration
|
||||
# Threads: 2 threads, will synchronize iterations
|
||||
# Benchmark mode: Throughput, ops/time
|
||||
# Benchmark: com.ankurm.hashmapconcurrenthashmap.PutGetBenchmark.concurrentHashMapPutGet
|
||||
|
||||
# Run progress: 0.00% complete, ETA 00:00:16
|
||||
# Fork: 1 of 1
|
||||
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by org.openjdk.jmh.util.Utils (file:/home/claude/java-core-examples/hashmap-concurrenthashmap/target/benchmarks.jar)
|
||||
WARNING: Please consider reporting this to the maintainers of class org.openjdk.jmh.util.Utils
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
|
||||
# Warmup Iteration 1: 39233.654 ops/ms
|
||||
# Warmup Iteration 2: 39452.589 ops/ms
|
||||
# Warmup Iteration 3: 48184.915 ops/ms
|
||||
Iteration 1: 47466.755 ops/ms
|
||||
Iteration 2: 49016.648 ops/ms
|
||||
Iteration 3: 45435.780 ops/ms
|
||||
Iteration 4: 46289.315 ops/ms
|
||||
Iteration 5: 48645.768 ops/ms
|
||||
|
||||
|
||||
Result "com.ankurm.hashmapconcurrenthashmap.PutGetBenchmark.concurrentHashMapPutGet":
|
||||
47370.853 ±(99.9%) 5858.003 ops/ms [Average]
|
||||
(min, avg, max) = (45435.780, 47370.853, 49016.648), stdev = 1521.305
|
||||
CI (99.9%): [41512.850, 53228.857] (assumes normal distribution)
|
||||
|
||||
|
||||
# JMH version: 1.37
|
||||
# VM version: JDK 25.0.4.1, OpenJDK 64-Bit Server VM, 25.0.4.1+1-LTS
|
||||
# VM invoker: /tmp/tools/jdk-25.0.4.1+1/bin/java
|
||||
# VM options: -Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts -Djavax.net.ssl.trustStoreType=JKS -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=36265 -Dhttp.nonProxyHosts=localhost|127.0.0.1|::1|127.*|0.*|::|169.254.*|api.anthropic.com|api-staging.anthropic.com|api-pr-preview.anthropic.com|mcp-proxy.anthropic.com|mcp-proxy-staging.anthropic.com|registry.npmjs.org|jsr.io|npm.jsr.io|pypi.org|files.pythonhosted.org|index.crates.io|proxy.golang.org|host.docker.internal|10.*|172.16.*|172.17.*|172.18.*|172.19.*|172.20.*|172.21.*|172.22.*|172.23.*|172.24.*|172.25.*|172.26.*|172.27.*|172.28.*|172.29.*|172.30.*|172.31.*|192.168.*|100.64.0.0/10|*.svc.cluster.local|*.svc.cluster.local -Djdk.http.auth.tunneling.disabledSchemes= -Djdk.http.auth.proxying.disabledSchemes=
|
||||
# Blackhole mode: compiler (auto-detected, use -Djmh.blackhole.autoDetect=false to disable)
|
||||
# Warmup: 3 iterations, 1 s each
|
||||
# Measurement: 5 iterations, 1 s each
|
||||
# Timeout: 10 min per iteration
|
||||
# Threads: 2 threads, will synchronize iterations
|
||||
# Benchmark mode: Throughput, ops/time
|
||||
# Benchmark: com.ankurm.hashmapconcurrenthashmap.PutGetBenchmark.synchronizedHashMapPutGet
|
||||
|
||||
# Run progress: 50.00% complete, ETA 00:00:08
|
||||
# Fork: 1 of 1
|
||||
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by org.openjdk.jmh.util.Utils (file:/home/claude/java-core-examples/hashmap-concurrenthashmap/target/benchmarks.jar)
|
||||
WARNING: Please consider reporting this to the maintainers of class org.openjdk.jmh.util.Utils
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
|
||||
# Warmup Iteration 1: 8475.811 ops/ms
|
||||
# Warmup Iteration 2: 7944.591 ops/ms
|
||||
# Warmup Iteration 3: 6576.291 ops/ms
|
||||
Iteration 1: 8300.960 ops/ms
|
||||
Iteration 2: 7385.743 ops/ms
|
||||
Iteration 3: 6304.540 ops/ms
|
||||
Iteration 4: 11817.370 ops/ms
|
||||
Iteration 5: 7213.951 ops/ms
|
||||
|
||||
|
||||
Result "com.ankurm.hashmapconcurrenthashmap.PutGetBenchmark.synchronizedHashMapPutGet":
|
||||
8204.513 ±(99.9%) 8241.532 ops/ms [Average]
|
||||
(min, avg, max) = (6304.540, 8204.513, 11817.370), stdev = 2140.300
|
||||
CI (99.9%): [≈ 0, 16446.045] (assumes normal distribution)
|
||||
|
||||
|
||||
# Run complete. Total time: 00:00:16
|
||||
|
||||
REMEMBER: The numbers below are just data. To gain reusable insights, you need to follow up on
|
||||
why the numbers are the way they are. Use profilers (see -prof, -lprof), design factorial
|
||||
experiments, perform baseline and negative tests that provide experimental control, make sure
|
||||
the benchmarking environment is safe on JVM/OS/HW level, ask for reviews from the domain experts.
|
||||
Do not assume the numbers tell you what you want them to tell.
|
||||
|
||||
NOTE: Current JVM experimentally supports Compiler Blackholes, and they are in use. Please exercise
|
||||
extra caution when trusting the results, look into the generated code to check the benchmark still
|
||||
works, and factor in a small probability of new VM bugs. Additionally, while comparisons between
|
||||
different JVMs are already problematic, the performance difference caused by different Blackhole
|
||||
modes can be very significant. Please make sure you use the consistent Blackhole mode for comparisons.
|
||||
|
||||
Benchmark Mode Cnt Score Error Units
|
||||
PutGetBenchmark.concurrentHashMapPutGet thrpt 5 47370.853 ± 5858.003 ops/ms
|
||||
PutGetBenchmark.synchronizedHashMapPutGet thrpt 5 8204.513 ± 8241.532 ops/ms
|
||||
@@ -0,0 +1,91 @@
|
||||
$ java -jar benchmarks.jar PutGetBenchmark -t 4
|
||||
|
||||
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by org.openjdk.jmh.util.Utils (file:/home/claude/java-core-examples/hashmap-concurrenthashmap/target/benchmarks.jar)
|
||||
WARNING: Please consider reporting this to the maintainers of class org.openjdk.jmh.util.Utils
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
|
||||
# JMH version: 1.37
|
||||
# VM version: JDK 25.0.4.1, OpenJDK 64-Bit Server VM, 25.0.4.1+1-LTS
|
||||
# VM invoker: /tmp/tools/jdk-25.0.4.1+1/bin/java
|
||||
# VM options: -Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts -Djavax.net.ssl.trustStoreType=JKS -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=36265 -Dhttp.nonProxyHosts=localhost|127.0.0.1|::1|127.*|0.*|::|169.254.*|api.anthropic.com|api-staging.anthropic.com|api-pr-preview.anthropic.com|mcp-proxy.anthropic.com|mcp-proxy-staging.anthropic.com|registry.npmjs.org|jsr.io|npm.jsr.io|pypi.org|files.pythonhosted.org|index.crates.io|proxy.golang.org|host.docker.internal|10.*|172.16.*|172.17.*|172.18.*|172.19.*|172.20.*|172.21.*|172.22.*|172.23.*|172.24.*|172.25.*|172.26.*|172.27.*|172.28.*|172.29.*|172.30.*|172.31.*|192.168.*|100.64.0.0/10|*.svc.cluster.local|*.svc.cluster.local -Djdk.http.auth.tunneling.disabledSchemes= -Djdk.http.auth.proxying.disabledSchemes=
|
||||
# Blackhole mode: compiler (auto-detected, use -Djmh.blackhole.autoDetect=false to disable)
|
||||
# Warmup: 3 iterations, 1 s each
|
||||
# Measurement: 5 iterations, 1 s each
|
||||
# Timeout: 10 min per iteration
|
||||
# Threads: 4 threads, will synchronize iterations
|
||||
# Benchmark mode: Throughput, ops/time
|
||||
# Benchmark: com.ankurm.hashmapconcurrenthashmap.PutGetBenchmark.concurrentHashMapPutGet
|
||||
|
||||
# Run progress: 0.00% complete, ETA 00:00:16
|
||||
# Fork: 1 of 1
|
||||
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by org.openjdk.jmh.util.Utils (file:/home/claude/java-core-examples/hashmap-concurrenthashmap/target/benchmarks.jar)
|
||||
WARNING: Please consider reporting this to the maintainers of class org.openjdk.jmh.util.Utils
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
|
||||
# Warmup Iteration 1: 40669.632 ops/ms
|
||||
# Warmup Iteration 2: 42866.944 ops/ms
|
||||
# Warmup Iteration 3: 46923.803 ops/ms
|
||||
Iteration 1: 37839.870 ops/ms
|
||||
Iteration 2: 47224.405 ops/ms
|
||||
Iteration 3: 48408.338 ops/ms
|
||||
Iteration 4: 47520.187 ops/ms
|
||||
Iteration 5: 50097.930 ops/ms
|
||||
|
||||
|
||||
Result "com.ankurm.hashmapconcurrenthashmap.PutGetBenchmark.concurrentHashMapPutGet":
|
||||
46218.146 ±(99.9%) 18542.465 ops/ms [Average]
|
||||
(min, avg, max) = (37839.870, 46218.146, 50097.930), stdev = 4815.419
|
||||
CI (99.9%): [27675.681, 64760.611] (assumes normal distribution)
|
||||
|
||||
|
||||
# JMH version: 1.37
|
||||
# VM version: JDK 25.0.4.1, OpenJDK 64-Bit Server VM, 25.0.4.1+1-LTS
|
||||
# VM invoker: /tmp/tools/jdk-25.0.4.1+1/bin/java
|
||||
# VM options: -Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts -Djavax.net.ssl.trustStoreType=JKS -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=36265 -Dhttp.nonProxyHosts=localhost|127.0.0.1|::1|127.*|0.*|::|169.254.*|api.anthropic.com|api-staging.anthropic.com|api-pr-preview.anthropic.com|mcp-proxy.anthropic.com|mcp-proxy-staging.anthropic.com|registry.npmjs.org|jsr.io|npm.jsr.io|pypi.org|files.pythonhosted.org|index.crates.io|proxy.golang.org|host.docker.internal|10.*|172.16.*|172.17.*|172.18.*|172.19.*|172.20.*|172.21.*|172.22.*|172.23.*|172.24.*|172.25.*|172.26.*|172.27.*|172.28.*|172.29.*|172.30.*|172.31.*|192.168.*|100.64.0.0/10|*.svc.cluster.local|*.svc.cluster.local -Djdk.http.auth.tunneling.disabledSchemes= -Djdk.http.auth.proxying.disabledSchemes=
|
||||
# Blackhole mode: compiler (auto-detected, use -Djmh.blackhole.autoDetect=false to disable)
|
||||
# Warmup: 3 iterations, 1 s each
|
||||
# Measurement: 5 iterations, 1 s each
|
||||
# Timeout: 10 min per iteration
|
||||
# Threads: 4 threads, will synchronize iterations
|
||||
# Benchmark mode: Throughput, ops/time
|
||||
# Benchmark: com.ankurm.hashmapconcurrenthashmap.PutGetBenchmark.synchronizedHashMapPutGet
|
||||
|
||||
# Run progress: 50.00% complete, ETA 00:00:08
|
||||
# Fork: 1 of 1
|
||||
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by org.openjdk.jmh.util.Utils (file:/home/claude/java-core-examples/hashmap-concurrenthashmap/target/benchmarks.jar)
|
||||
WARNING: Please consider reporting this to the maintainers of class org.openjdk.jmh.util.Utils
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
|
||||
# Warmup Iteration 1: 7626.664 ops/ms
|
||||
# Warmup Iteration 2: 8530.844 ops/ms
|
||||
# Warmup Iteration 3: 9799.982 ops/ms
|
||||
Iteration 1: 9978.021 ops/ms
|
||||
Iteration 2: 9500.059 ops/ms
|
||||
Iteration 3: 8813.332 ops/ms
|
||||
Iteration 4: 9502.575 ops/ms
|
||||
Iteration 5: 9466.454 ops/ms
|
||||
|
||||
|
||||
Result "com.ankurm.hashmapconcurrenthashmap.PutGetBenchmark.synchronizedHashMapPutGet":
|
||||
9452.088 ±(99.9%) 1598.912 ops/ms [Average]
|
||||
(min, avg, max) = (8813.332, 9452.088, 9978.021), stdev = 415.232
|
||||
CI (99.9%): [7853.176, 11051.000] (assumes normal distribution)
|
||||
|
||||
|
||||
# Run complete. Total time: 00:00:17
|
||||
|
||||
REMEMBER: The numbers below are just data. To gain reusable insights, you need to follow up on
|
||||
why the numbers are the way they are. Use profilers (see -prof, -lprof), design factorial
|
||||
experiments, perform baseline and negative tests that provide experimental control, make sure
|
||||
the benchmarking environment is safe on JVM/OS/HW level, ask for reviews from the domain experts.
|
||||
Do not assume the numbers tell you what you want them to tell.
|
||||
|
||||
NOTE: Current JVM experimentally supports Compiler Blackholes, and they are in use. Please exercise
|
||||
extra caution when trusting the results, look into the generated code to check the benchmark still
|
||||
works, and factor in a small probability of new VM bugs. Additionally, while comparisons between
|
||||
different JVMs are already problematic, the performance difference caused by different Blackhole
|
||||
modes can be very significant. Please make sure you use the consistent Blackhole mode for comparisons.
|
||||
|
||||
Benchmark Mode Cnt Score Error Units
|
||||
PutGetBenchmark.concurrentHashMapPutGet thrpt 5 46218.146 ± 18542.465 ops/ms
|
||||
PutGetBenchmark.synchronizedHashMapPutGet thrpt 5 9452.088 ± 1598.912 ops/ms
|
||||
@@ -0,0 +1,91 @@
|
||||
$ java -jar benchmarks.jar PutGetBenchmark -t 8
|
||||
|
||||
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by org.openjdk.jmh.util.Utils (file:/home/claude/java-core-examples/hashmap-concurrenthashmap/target/benchmarks.jar)
|
||||
WARNING: Please consider reporting this to the maintainers of class org.openjdk.jmh.util.Utils
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
|
||||
# JMH version: 1.37
|
||||
# VM version: JDK 25.0.4.1, OpenJDK 64-Bit Server VM, 25.0.4.1+1-LTS
|
||||
# VM invoker: /tmp/tools/jdk-25.0.4.1+1/bin/java
|
||||
# VM options: -Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts -Djavax.net.ssl.trustStoreType=JKS -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=36265 -Dhttp.nonProxyHosts=localhost|127.0.0.1|::1|127.*|0.*|::|169.254.*|api.anthropic.com|api-staging.anthropic.com|api-pr-preview.anthropic.com|mcp-proxy.anthropic.com|mcp-proxy-staging.anthropic.com|registry.npmjs.org|jsr.io|npm.jsr.io|pypi.org|files.pythonhosted.org|index.crates.io|proxy.golang.org|host.docker.internal|10.*|172.16.*|172.17.*|172.18.*|172.19.*|172.20.*|172.21.*|172.22.*|172.23.*|172.24.*|172.25.*|172.26.*|172.27.*|172.28.*|172.29.*|172.30.*|172.31.*|192.168.*|100.64.0.0/10|*.svc.cluster.local|*.svc.cluster.local -Djdk.http.auth.tunneling.disabledSchemes= -Djdk.http.auth.proxying.disabledSchemes=
|
||||
# Blackhole mode: compiler (auto-detected, use -Djmh.blackhole.autoDetect=false to disable)
|
||||
# Warmup: 3 iterations, 1 s each
|
||||
# Measurement: 5 iterations, 1 s each
|
||||
# Timeout: 10 min per iteration
|
||||
# Threads: 8 threads, will synchronize iterations
|
||||
# Benchmark mode: Throughput, ops/time
|
||||
# Benchmark: com.ankurm.hashmapconcurrenthashmap.PutGetBenchmark.concurrentHashMapPutGet
|
||||
|
||||
# Run progress: 0.00% complete, ETA 00:00:16
|
||||
# Fork: 1 of 1
|
||||
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by org.openjdk.jmh.util.Utils (file:/home/claude/java-core-examples/hashmap-concurrenthashmap/target/benchmarks.jar)
|
||||
WARNING: Please consider reporting this to the maintainers of class org.openjdk.jmh.util.Utils
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
|
||||
# Warmup Iteration 1: 34283.922 ops/ms
|
||||
# Warmup Iteration 2: 30625.356 ops/ms
|
||||
# Warmup Iteration 3: 45011.575 ops/ms
|
||||
Iteration 1: 45542.175 ops/ms
|
||||
Iteration 2: 43859.481 ops/ms
|
||||
Iteration 3: 40886.605 ops/ms
|
||||
Iteration 4: 40557.579 ops/ms
|
||||
Iteration 5: 45152.391 ops/ms
|
||||
|
||||
|
||||
Result "com.ankurm.hashmapconcurrenthashmap.PutGetBenchmark.concurrentHashMapPutGet":
|
||||
43199.646 ±(99.9%) 9044.242 ops/ms [Average]
|
||||
(min, avg, max) = (40557.579, 43199.646, 45542.175), stdev = 2348.761
|
||||
CI (99.9%): [34155.404, 52243.888] (assumes normal distribution)
|
||||
|
||||
|
||||
# JMH version: 1.37
|
||||
# VM version: JDK 25.0.4.1, OpenJDK 64-Bit Server VM, 25.0.4.1+1-LTS
|
||||
# VM invoker: /tmp/tools/jdk-25.0.4.1+1/bin/java
|
||||
# VM options: -Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts -Djavax.net.ssl.trustStoreType=JKS -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=36265 -Dhttp.nonProxyHosts=localhost|127.0.0.1|::1|127.*|0.*|::|169.254.*|api.anthropic.com|api-staging.anthropic.com|api-pr-preview.anthropic.com|mcp-proxy.anthropic.com|mcp-proxy-staging.anthropic.com|registry.npmjs.org|jsr.io|npm.jsr.io|pypi.org|files.pythonhosted.org|index.crates.io|proxy.golang.org|host.docker.internal|10.*|172.16.*|172.17.*|172.18.*|172.19.*|172.20.*|172.21.*|172.22.*|172.23.*|172.24.*|172.25.*|172.26.*|172.27.*|172.28.*|172.29.*|172.30.*|172.31.*|192.168.*|100.64.0.0/10|*.svc.cluster.local|*.svc.cluster.local -Djdk.http.auth.tunneling.disabledSchemes= -Djdk.http.auth.proxying.disabledSchemes=
|
||||
# Blackhole mode: compiler (auto-detected, use -Djmh.blackhole.autoDetect=false to disable)
|
||||
# Warmup: 3 iterations, 1 s each
|
||||
# Measurement: 5 iterations, 1 s each
|
||||
# Timeout: 10 min per iteration
|
||||
# Threads: 8 threads, will synchronize iterations
|
||||
# Benchmark mode: Throughput, ops/time
|
||||
# Benchmark: com.ankurm.hashmapconcurrenthashmap.PutGetBenchmark.synchronizedHashMapPutGet
|
||||
|
||||
# Run progress: 50.00% complete, ETA 00:00:08
|
||||
# Fork: 1 of 1
|
||||
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by org.openjdk.jmh.util.Utils (file:/home/claude/java-core-examples/hashmap-concurrenthashmap/target/benchmarks.jar)
|
||||
WARNING: Please consider reporting this to the maintainers of class org.openjdk.jmh.util.Utils
|
||||
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
|
||||
# Warmup Iteration 1: 6343.850 ops/ms
|
||||
# Warmup Iteration 2: 8158.137 ops/ms
|
||||
# Warmup Iteration 3: 7888.039 ops/ms
|
||||
Iteration 1: 7586.558 ops/ms
|
||||
Iteration 2: 8206.180 ops/ms
|
||||
Iteration 3: 7242.487 ops/ms
|
||||
Iteration 4: 7706.814 ops/ms
|
||||
Iteration 5: 8379.430 ops/ms
|
||||
|
||||
|
||||
Result "com.ankurm.hashmapconcurrenthashmap.PutGetBenchmark.synchronizedHashMapPutGet":
|
||||
7824.294 ±(99.9%) 1788.407 ops/ms [Average]
|
||||
(min, avg, max) = (7242.487, 7824.294, 8379.430), stdev = 464.444
|
||||
CI (99.9%): [6035.887, 9612.701] (assumes normal distribution)
|
||||
|
||||
|
||||
# Run complete. Total time: 00:00:17
|
||||
|
||||
REMEMBER: The numbers below are just data. To gain reusable insights, you need to follow up on
|
||||
why the numbers are the way they are. Use profilers (see -prof, -lprof), design factorial
|
||||
experiments, perform baseline and negative tests that provide experimental control, make sure
|
||||
the benchmarking environment is safe on JVM/OS/HW level, ask for reviews from the domain experts.
|
||||
Do not assume the numbers tell you what you want them to tell.
|
||||
|
||||
NOTE: Current JVM experimentally supports Compiler Blackholes, and they are in use. Please exercise
|
||||
extra caution when trusting the results, look into the generated code to check the benchmark still
|
||||
works, and factor in a small probability of new VM bugs. Additionally, while comparisons between
|
||||
different JVMs are already problematic, the performance difference caused by different Blackhole
|
||||
modes can be very significant. Please make sure you use the consistent Blackhole mode for comparisons.
|
||||
|
||||
Benchmark Mode Cnt Score Error Units
|
||||
PutGetBenchmark.concurrentHashMapPutGet thrpt 5 43199.646 ± 9044.242 ops/ms
|
||||
PutGetBenchmark.synchronizedHashMapPutGet thrpt 5 7824.294 ± 1788.407 ops/ms
|
||||
@@ -0,0 +1,4 @@
|
||||
-------------------------------------------------------------------------------
|
||||
Test set: com.ankurm.hashmapconcurrenthashmap.MapClaimsTest
|
||||
-------------------------------------------------------------------------------
|
||||
Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.101 s -- in com.ankurm.hashmapconcurrenthashmap.MapClaimsTest
|
||||
Reference in New Issue
Block a user