Comments for https://horstmann.com/unblog/2022-01-06/index.html
Comments for: https://horstmann.com/unblog/2022-01-06/index.html
- JPetr Janeček @JanecekPetr
Okay, so the server results say it's the same.
And yet, one obvious difference is the GC. Does it make a difference (mainly for the parallel version) to run with -XX:+UseParallelGC?- KHeinz Kabutz @kabutz
GC is not the bottleneck, ergo, it is pretty much irrelevant which algorithm we use. I just used the defaults (Throughput for Java 8 and G1 for Java 17). Since it's not close to the bottleneck, it does not make a difference.
- PPeter Veentjer @pveentjer
Nitpick warning: Even if there is no garbage being created, it doesn't mean that the GC algorithm can't have an impact. E.g with ZGC there is overhead when dereferencing a pointer from the heap due to the load barrier.
- KHeinz Kabutz @kabutz
The original article shows a completely pointless benchmark, measuring an exponential time algorithm that has a logarithmic time version, run on inappropriate hardware, all just to generate clicks for the original author.
And we're worrying about what GC algorithm was used ...
- JPetr Janeček @JanecekPetr
Gentlemen! We're all professionals. Calm down.
I believe we all know Java 17 is considerably faster for many operations (and it still doesn't matter as my applications are generally DB-bound and/or IO-bound). But this is a (provocative and not very deep) article about a potential regression I could not understand at first sight, so I wondered aloud whether the difference might be G1. It's not and it was pretty clear once I gave it a second sight. I didn't dig deeper once I've seen Mr. Kabutz server results, though.
Mr. Ventjeer's general remark about GCs having their own costs (with different GCs having different costs in different places) is obviously true and might be interesting to other readers.
Let's keep it there :).
- KHeinz Kabutz @kabutz
Right, and according to my measurements on a decent piece of hardware, there is no difference.
You are correct though - if there was more object allocation, then the difference between G1 / ZGC / Throughput would show. In that case it would make sense to run the benchmark with at least the same GC.
- LKartik Ohri @lucifer
Hi! Can you share the specs of the server you ran the benchmark on ?
Actually, I too was intrigued by the original post and wondered what whether the post was correct or not. Thus, I had written a similar JMH benchmark a couple of months ago. https://github.com/amCap1712/17vs8 .
I ran it on a server with
Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
CPU and64GB
RAM. (Not sure whether this is decent hardware or not) My results were similar to the original post: https://gist.github.com/amCap1712/d4ce26356e19f0bf8b7e044463b51851#file-benchmark-results. (Please ignore the remaining dis-assemblies, those were part of a wild goose chase on recursion vs iteration on Java 8 and 17.) However, its a multi tenant machine and I do not have enough know on how to prep a machine for benchmarks so was unsure of the results. As you have shown, those were indeed wrong.- KHeinz Kabutz @kabutz
Here is what I use for my benchmarks: https://www.hetzner.com/dedicated-rootserver/ax41-nvme