Files
Claude 4511cc6e6b parallel-streams: JMH benchmarks and demos for when parallel streams are slower
N x Q model, source splittability, boxing, ordered operations, common-pool
starvation, and parallel-stream correctness bugs. Captured output in output/.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b6hCTuFrQT8xKmmMrF
2026-11-17 23:23:21 +05:30

284 lines
15 KiB
Plaintext

# JMH version: 1.37
# VM version: JDK 25.0.5, OpenJDK 64-Bit Server VM, 25.0.5+8-LTS
# VM invoker: /tmp/tools/jdk-25.0.5+8/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=42575 -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: Average time, time/op
# Benchmark: com.ankurm.parallelstreams.BoxingBenchmark.boxed_par
# Run progress: 0.00% complete, ETA 00:00:32
# Fork: 1 of 1
# Warmup Iteration 1: 974.986 us/op
# Warmup Iteration 2: 848.792 us/op
# Warmup Iteration 3: 796.211 us/op
Iteration 1: 870.351 us/op
gc.alloc.rate: 1.213 MB/sec
gc.alloc.rate.norm: 1107.770 B/op
gc.count: ≈ 0 counts
Iteration 2: 824.111 us/op
gc.alloc.rate: 1.281 MB/sec
gc.alloc.rate.norm: 1108.642 B/op
gc.count: ≈ 0 counts
Iteration 3: 845.852 us/op
gc.alloc.rate: 1.243 MB/sec
gc.alloc.rate.norm: 1107.741 B/op
gc.count: ≈ 0 counts
Iteration 4: 861.177 us/op
gc.alloc.rate: 1.227 MB/sec
gc.alloc.rate.norm: 1109.962 B/op
gc.count: ≈ 0 counts
Iteration 5: 886.850 us/op
gc.alloc.rate: 1.190 MB/sec
gc.alloc.rate.norm: 1106.539 B/op
gc.count: ≈ 0 counts
Result "com.ankurm.parallelstreams.BoxingBenchmark.boxed_par":
857.668 ±(99.9%) 92.144 us/op [Average]
(min, avg, max) = (824.111, 857.668, 886.850), stdev = 23.930
CI (99.9%): [765.524, 949.812] (assumes normal distribution)
Secondary result "com.ankurm.parallelstreams.BoxingBenchmark.boxed_par:gc.alloc.rate":
1.231 ±(99.9%) 0.132 MB/sec [Average]
(min, avg, max) = (1.190, 1.231, 1.281), stdev = 0.034
CI (99.9%): [1.099, 1.362] (assumes normal distribution)
Secondary result "com.ankurm.parallelstreams.BoxingBenchmark.boxed_par:gc.alloc.rate.norm":
1108.131 ±(99.9%) 4.882 B/op [Average]
(min, avg, max) = (1106.539, 1108.131, 1109.962), stdev = 1.268
CI (99.9%): [1103.249, 1113.013] (assumes normal distribution)
Secondary result "com.ankurm.parallelstreams.BoxingBenchmark.boxed_par:gc.count":
≈ 0 counts
# JMH version: 1.37
# VM version: JDK 25.0.5, OpenJDK 64-Bit Server VM, 25.0.5+8-LTS
# VM invoker: /tmp/tools/jdk-25.0.5+8/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=42575 -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: Average time, time/op
# Benchmark: com.ankurm.parallelstreams.BoxingBenchmark.boxed_seq
# Run progress: 25.00% complete, ETA 00:00:24
# Fork: 1 of 1
# Warmup Iteration 1: 1431.858 us/op
# Warmup Iteration 2: 1497.100 us/op
# Warmup Iteration 3: 1432.571 us/op
Iteration 1: 1389.004 us/op
gc.alloc.rate: 0.232 MB/sec
gc.alloc.rate.norm: 337.709 B/op
gc.count: ≈ 0 counts
Iteration 2: 1421.737 us/op
gc.alloc.rate: 0.227 MB/sec
gc.alloc.rate.norm: 337.943 B/op
gc.count: ≈ 0 counts
Iteration 3: 1439.071 us/op
gc.alloc.rate: 0.224 MB/sec
gc.alloc.rate.norm: 338.029 B/op
gc.count: ≈ 0 counts
Iteration 4: 1446.336 us/op
gc.alloc.rate: 0.223 MB/sec
gc.alloc.rate.norm: 338.116 B/op
gc.count: ≈ 0 counts
Iteration 5: 1482.209 us/op
gc.alloc.rate: 0.218 MB/sec
gc.alloc.rate.norm: 338.584 B/op
gc.count: ≈ 0 counts
Result "com.ankurm.parallelstreams.BoxingBenchmark.boxed_seq":
1435.671 ±(99.9%) 131.474 us/op [Average]
(min, avg, max) = (1389.004, 1435.671, 1482.209), stdev = 34.143
CI (99.9%): [1304.197, 1567.146] (assumes normal distribution)
Secondary result "com.ankurm.parallelstreams.BoxingBenchmark.boxed_seq:gc.alloc.rate":
0.224 ±(99.9%) 0.020 MB/sec [Average]
(min, avg, max) = (0.218, 0.224, 0.232), stdev = 0.005
CI (99.9%): [0.205, 0.244] (assumes normal distribution)
Secondary result "com.ankurm.parallelstreams.BoxingBenchmark.boxed_seq:gc.alloc.rate.norm":
338.076 ±(99.9%) 1.239 B/op [Average]
(min, avg, max) = (337.709, 338.076, 338.584), stdev = 0.322
CI (99.9%): [336.837, 339.315] (assumes normal distribution)
Secondary result "com.ankurm.parallelstreams.BoxingBenchmark.boxed_seq:gc.count":
≈ 0 counts
# JMH version: 1.37
# VM version: JDK 25.0.5, OpenJDK 64-Bit Server VM, 25.0.5+8-LTS
# VM invoker: /tmp/tools/jdk-25.0.5+8/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=42575 -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: Average time, time/op
# Benchmark: com.ankurm.parallelstreams.BoxingBenchmark.primitive_par
# Run progress: 50.00% complete, ETA 00:00:16
# Fork: 1 of 1
# Warmup Iteration 1: 205.937 us/op
# Warmup Iteration 2: 170.623 us/op
# Warmup Iteration 3: 162.141 us/op
Iteration 1: 161.161 us/op
gc.alloc.rate: 5.462 MB/sec
gc.alloc.rate.norm: 923.506 B/op
gc.count: ≈ 0 counts
Iteration 2: 164.425 us/op
gc.alloc.rate: 5.369 MB/sec
gc.alloc.rate.norm: 925.919 B/op
gc.count: ≈ 0 counts
Iteration 3: 166.830 us/op
gc.alloc.rate: 5.271 MB/sec
gc.alloc.rate.norm: 922.734 B/op
gc.count: ≈ 0 counts
Iteration 4: 155.618 us/op
gc.alloc.rate: 5.651 MB/sec
gc.alloc.rate.norm: 922.257 B/op
gc.count: ≈ 0 counts
Iteration 5: 153.176 us/op
gc.alloc.rate: 5.726 MB/sec
gc.alloc.rate.norm: 919.993 B/op
gc.count: ≈ 0 counts
Result "com.ankurm.parallelstreams.BoxingBenchmark.primitive_par":
160.242 ±(99.9%) 22.209 us/op [Average]
(min, avg, max) = (153.176, 160.242, 166.830), stdev = 5.768
CI (99.9%): [138.033, 182.451] (assumes normal distribution)
Secondary result "com.ankurm.parallelstreams.BoxingBenchmark.primitive_par:gc.alloc.rate":
5.496 ±(99.9%) 0.733 MB/sec [Average]
(min, avg, max) = (5.271, 5.496, 5.726), stdev = 0.190
CI (99.9%): [4.763, 6.229] (assumes normal distribution)
Secondary result "com.ankurm.parallelstreams.BoxingBenchmark.primitive_par:gc.alloc.rate.norm":
922.882 ±(99.9%) 8.253 B/op [Average]
(min, avg, max) = (919.993, 922.882, 925.919), stdev = 2.143
CI (99.9%): [914.629, 931.135] (assumes normal distribution)
Secondary result "com.ankurm.parallelstreams.BoxingBenchmark.primitive_par:gc.count":
≈ 0 counts
# JMH version: 1.37
# VM version: JDK 25.0.5, OpenJDK 64-Bit Server VM, 25.0.5+8-LTS
# VM invoker: /tmp/tools/jdk-25.0.5+8/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=42575 -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: Average time, time/op
# Benchmark: com.ankurm.parallelstreams.BoxingBenchmark.primitive_seq
# Run progress: 75.00% complete, ETA 00:00:08
# Fork: 1 of 1
# Warmup Iteration 1: 273.688 us/op
# Warmup Iteration 2: 265.275 us/op
# Warmup Iteration 3: 264.934 us/op
Iteration 1: 274.675 us/op
gc.alloc.rate: 0.645 MB/sec
gc.alloc.rate.norm: 185.921 B/op
gc.count: ≈ 0 counts
Iteration 2: 271.925 us/op
gc.alloc.rate: 0.651 MB/sec
gc.alloc.rate.norm: 185.902 B/op
gc.count: ≈ 0 counts
Iteration 3: 269.727 us/op
gc.alloc.rate: 0.655 MB/sec
gc.alloc.rate.norm: 185.887 B/op
gc.count: ≈ 0 counts
Iteration 4: 266.509 us/op
gc.alloc.rate: 0.665 MB/sec
gc.alloc.rate.norm: 185.865 B/op
gc.count: ≈ 0 counts
Iteration 5: 265.184 us/op
gc.alloc.rate: 0.668 MB/sec
gc.alloc.rate.norm: 185.847 B/op
gc.count: ≈ 0 counts
Result "com.ankurm.parallelstreams.BoxingBenchmark.primitive_seq":
269.604 ±(99.9%) 14.943 us/op [Average]
(min, avg, max) = (265.184, 269.604, 274.675), stdev = 3.881
CI (99.9%): [254.660, 284.547] (assumes normal distribution)
Secondary result "com.ankurm.parallelstreams.BoxingBenchmark.primitive_seq:gc.alloc.rate":
0.657 ±(99.9%) 0.036 MB/sec [Average]
(min, avg, max) = (0.645, 0.657, 0.668), stdev = 0.009
CI (99.9%): [0.621, 0.693] (assumes normal distribution)
Secondary result "com.ankurm.parallelstreams.BoxingBenchmark.primitive_seq:gc.alloc.rate.norm":
185.884 ±(99.9%) 0.113 B/op [Average]
(min, avg, max) = (185.847, 185.884, 185.921), stdev = 0.029
CI (99.9%): [185.771, 185.997] (assumes normal distribution)
Secondary result "com.ankurm.parallelstreams.BoxingBenchmark.primitive_seq:gc.count":
≈ 0 counts
# Run complete. Total time: 00:00:33
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
BoxingBenchmark.boxed_par avgt 5 857.668 ± 92.144 us/op
BoxingBenchmark.boxed_par:gc.alloc.rate avgt 5 1.231 ± 0.132 MB/sec
BoxingBenchmark.boxed_par:gc.alloc.rate.norm avgt 5 1108.131 ± 4.882 B/op
BoxingBenchmark.boxed_par:gc.count avgt 5 ≈ 0 counts
BoxingBenchmark.boxed_seq avgt 5 1435.671 ± 131.474 us/op
BoxingBenchmark.boxed_seq:gc.alloc.rate avgt 5 0.224 ± 0.020 MB/sec
BoxingBenchmark.boxed_seq:gc.alloc.rate.norm avgt 5 338.076 ± 1.239 B/op
BoxingBenchmark.boxed_seq:gc.count avgt 5 ≈ 0 counts
BoxingBenchmark.primitive_par avgt 5 160.242 ± 22.209 us/op
BoxingBenchmark.primitive_par:gc.alloc.rate avgt 5 5.496 ± 0.733 MB/sec
BoxingBenchmark.primitive_par:gc.alloc.rate.norm avgt 5 922.882 ± 8.253 B/op
BoxingBenchmark.primitive_par:gc.count avgt 5 ≈ 0 counts
BoxingBenchmark.primitive_seq avgt 5 269.604 ± 14.943 us/op
BoxingBenchmark.primitive_seq:gc.alloc.rate avgt 5 0.657 ± 0.036 MB/sec
BoxingBenchmark.primitive_seq:gc.alloc.rate.norm avgt 5 185.884 ± 0.113 B/op
BoxingBenchmark.primitive_seq:gc.count avgt 5 ≈ 0 counts