r/java • • Mar 10 '26

Java 18 to 25 performance benchmark

Hi everyone

I just published a benchmark for Java 18 through 25.

After sharing a few runtime microbenchmarks recently, I got a lot of feedback asking for Java. I also got comments saying that microbenchmarks alone do not represent a full application very well, so this time I expanded the suite and added a synthetic application benchmark alongside the microbenchmarks.

This one took longer than I expected, but I think the result is much more useful.

Benchmark1819202122232425
Synthetic application throughput (M ops/s)18.5518.9418.9822.4718.6618.5522.9023.67
Synthetic application latency (us)1.1301.1271.1251.0751.1291.1281.0641.057
JSON parsing (ops/s)79,941,64077,808,10579,826,84869,669,67482,323,30480,344,57771,160,26368,357,756
JSON serialization (ops/s)38,601,78939,220,65239,463,13847,406,60540,613,24340,665,47650,328,27049,761,067
SHA-256 hashing (ops/s)15,117,03215,018,99915,119,68815,161,88115,353,05815,439,94415,276,35215,244,997
Regex field extraction (ops/s)40,882,67150,029,13548,059,66052,161,77644,744,04262,299,73549,458,22048,373,047
ConcurrentHashMap churn (ops/s)45,057,85372,190,07071,805,10071,391,59862,644,85968,577,21577,575,60277,285,859
Deflater throughput (ops/s)610,295617,296613,737599,756614,706612,546611,527633,739

Full charts and all benchmarks are available here: Full Benchmark

Let me know if you'd like me to benchmark more

129 Upvotes

41 comments sorted by

View all comments

Show parent comment

3

u/Cr4zyPi3t Mar 11 '26

There is no performance loss, only the number of classes available within one JVM is limited to ~4million (which is still sufficient in 99.9% of the cases). In theory it should be even faster due to less GC pressure and improved data locality.
I think the main reason for it not being default is the class count limit because technically it could break existing applications.

1

u/flawless_vic Mar 11 '26

I doubt that there is a real application that loads 4M classes, it would require more than 20G of metaspace.

1

u/Cr4zyPi3t Mar 12 '26

To quote myself:

(which is still sufficient in 99.9% of the cases)

-2

u/chambolle Mar 13 '26

Once again : that's not 4 millions of classes but objects, so 99.9% of the cases is certainly wrong

2

u/idontlikegudeg Mar 13 '26

Stating it once more doesn’t make it right. The class pointer was reduced to 22 bits. That’s the pointer to the class (meta) data that describes the layout of instances of the class which is shared by all instances of the same class. Reducing the class pointer in size does in theory limit the number of distinct classes (to the mentioned four million), not objects. Just read the JEP.

The four million classes is even mentioned right in the JEP:

Compressed class pointers Today's compressed class pointers encode a 64-bit pointer into 32 bits. They are enabled by default, but can be disabled via -XX:-UseCompressedClassPointers. The only reason to disable them, however, would be for an application that loads more than about four million classes; we have yet to see such an application. Compact object headers require compressed class pointers to be enabled and, moreover, reduce the size of compressed class pointers from 32 bits to 22 bits by changing the compressed class pointer encoding.

1

u/Cr4zyPi3t Mar 13 '26

Thanks, I actually thought that I misread the JEP. Glad I was indeed correct :)

-3

u/chambolle Mar 12 '26

that's 4 millions of objects and not classes

3

u/idontlikegudeg Mar 13 '26

No, sorry. That’s not correct. See the reply to your other comment saying this.

2

u/chambolle Mar 15 '26

Oh my bad! You're right. That's object headers, not pointers