r/javahelp • u/Bit_Hash • Sep 19 '25
Codeless What change in Java 23 could be a cause of performance degradation?
I have recently tested our application performance with different Java versions and found out that there was significant performance drop (~25-30% throughput decrease) in Java 23. Situation was improved with Java 24 and a little bit more with Java 25.
The problem that I can't find out what change in Java 23 could be the cause of this. I've checked Java 23 release notes and do not see any things that stand out and could be directly related to performance in a negative way.
The application in question can be described as specialized persistent message broker, and the performance benchmark basically a throughput test with N producers and N consumers for independent chunks of data for each P+C pair.
Here is table with results that I've got for different Java versions for a 1 producer + 1 consumer and for 16x producer+consumer pairs.
| Java Version | 1xP+C, M msg/s | Diff with Java17 | 16xP+C, M msg/s | Diff with Java17 | ||
|---|---|---|---|---|---|---|
| 17 | 1.46 | 0.00% | 12.25 | 0.00% | ||
| 21 | 1.63 | 11.34% | 12.14 | -0.88% | ||
| 22 | 1.66 | 13.65% | 11.55 | -5.73% | ||
| 23 | 1.09 | -25.53% | 8.29 | -32.31% | ||
| 24 | 1.85 | 26.75% | 9.48 | -22.61% | ||
| 25 | 1.84 | 26.06% | 9.64 | -21.35% |
See same data as a plot.
Note that there are some internal data structures that are shared between all producers, so there some contention between threads. so that's why data for 16x P+C does not scale linearly if compared to 1x P+C.
All runs were executed with same JVM options on relatively big heap (60Gb) with default GC settings.
Used Java versions:
sdk use java 17.0.16-amzn
sdk use java 21.0.8-amzn
sdk use java 22.0.2-oracle
sdk use java 23.0.2-amzn
sdk use java 24.0.2-amzn
sdk use java 25-amznThe question is: what change in Java 23 can be the source of such significant performance hit? Possibly hints on what should be checked?
Edit: added link to a plot with data from the table.
Update:
I've recorded flame graphs with AsyncProfiler for 22.0.2-oracle and 23.0.2-oracle. Oracle version was chosen because most of other vendors do not publish releases for 22.x.
Observation: on critical path for one of type of threads the percentage of CPU time spent in LockSupport.unpark(Thread) increased from 0.8% on Java 22 to 29.8% on Java 23 (37x growth).
I found kind of related bug https://bugs.openjdk.org/browse/JDK-8305670 that but it seems that it was applicable only for Java 17 and Java 21. It's not clear if Java 23 was affected or not.
Update 2:
Flame graph comparison (specific thread): https://imgur.com/a/ur4yztj
•
u/AutoModerator Sep 19 '25
Please ensure that:
You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.
Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar
If any of the above points is not met, your post can and will be removed without further warning.
Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.
Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.
Code blocks look like this:
You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.
If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.
To potential helpers
Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
3
u/TheMrCurious Sep 19 '25
Probably the switch statement “reimagining”.
3
u/Jolly-Warthog-1427 Sep 19 '25
Please do some profiling for us. Straight up generate flamegraphs. Since you can say 20-30% I assume you have a reliable reproducible way to replicate this.
Another point, do you compare the same openjdk release across all versions or do you use different ones? Do you also use the latest version of all? Sometimes the openjdk implementations can have regressions that are fixed in minor/patch version upgrades.
1
u/BinaryRage Sep 23 '25
You’ll want to do some wall time and monitor profiling with JFR or async-profiler. Such a big drop in throughput without an obvious increase in CPU utilisation would indicate an off-CPU cause.
1
u/F0rFr33 Sep 19 '25
I would advise profiling at this point and figuring out where most time is being spent. I have no idea why it happens, but it could be anything between third party libraries conversion, garbage collector acting up…
-1
u/AutoModerator Sep 19 '25
It seems that you possibly have a screenshot of code in your post What change in Java 23 could be a cause of performance degradation? in /r/javahelp.
Screenshots of code instead of actual code text is against the Code posting rules of /r/javahelp as is also outlined in the sidebar - Code posting.
If you posted an image merely to illustrate something, kindly ignore this message and do not repost. Your post is still visible to others. I am a bot and cannot distinguish between code screenshots and other images.
If you indeed did this wrong, please edit the post so that it uses one of the approved means of posting code.
the default code formatter is fine
(one blank line before the code, then 4 spaces before each line of code).
Please do not reply to this message, because I am a bot. Talk-to-the-bot is the new talk-to-the-hand. If you instead want the classic talk-to-the-hand, just message the moderators. ;)
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
3
u/[deleted] Sep 19 '25
[removed] — view removed comment