fabienrenaud / java-json-benchmark

Performance testing of serialization and deserialization of Java JSON libraries
MIT License
965 stars 134 forks source link

Huge performance diff between dsljson and dsljson_reflection of serialization. #107

Open ZhaiMo15 opened 1 month ago

ZhaiMo15 commented 1 month ago

I ran the benchmark of serialization, but the result seemed wield, I'd like to know why.

Command: ./run ser --libs jackson,dsljson,dsljson_reflection --apis databind CPU: Intel(R) Xeon(R) Gold 5120 CPU @ 2.20GHz JMH info:

# JMH version: 1.35
# VM version: JDK 17.0.7-internal, OpenJDK 64-Bit Server VM, 17.0.7-internal+7
# VM invoker: /media/disk4/zhaimo03/project/jdk17u/build/linux-x86_64-server-release/images/jdk/bin/java
# VM options: -Xms2g -Xmx2g --add-opens=java.base/java.time=ALL-UNNAMED --add-modules=jdk.incubator.vector
# Blackhole mode: compiler (auto-detected, use -Djmh.blackhole.autoDetect=false to disable)
# Warmup: 5 iterations, 10 s each
# Measurement: 10 iterations, 3 s each
# Timeout: 10 min per iteration
# Threads: 55 threads, will synchronize iterations
# Benchmark mode: Throughput, ops/time

The result:

Benchmark                           Mode  Cnt         Score        Error  Units
Serialization.dsljson              thrpt   20  10941062.256 ± 107016.443  ops/s
Serialization.dsljson_reflection   thrpt   20   2246216.591 ± 214208.652  ops/s
Serialization.jackson              thrpt   20   5412225.364 ±  50381.440  ops/s

However the result in README shows:

Benchmark                           Mode  Cnt         Score        Error  Units
Serialization.dsljson              thrpt   20  1109612.051 ± 17248.711  ops/s
Serialization.dsljson_reflection   thrpt   20   801809.514 ± 6651.390  ops/s
Serialization.jackson              thrpt   20   668196.151 ±  1980.009  ops/s

I'm wondering why the performance of dsljson_reflection doesn't match? Thanks all.

SentryMan commented 1 month ago

I'd guess because one uses reflection and the other doesn't

ZhaiMo15 commented 1 month ago

Thanks for reply, but see the score, in README, reflection is still better than jackson. However, my bench shows reflection is way to slower than jackson.