JetBrains / JetBrainsRuntime

Runtime environment based on OpenJDK for running IntelliJ Platform-based products on Windows, macOS, and Linux
GNU General Public License v2.0
1.28k stars 193 forks source link

[WHY?] JBR JDK 21 is sooooo slow compared to super fast JBR JDK 17 #422

Open copyandexecute opened 1 month ago

copyandexecute commented 1 month ago

Hi, I'm coding minecraft mods with fabric and I loved jbr 17 class hotswapping it was so fast and I've never head any problem, but since minecraft 1.21 requires java 21 I had to switch... After hotswapping like 5 times I get this error:

grafik

After Adding these argument, it got a little bit better but not that good as with 17

-XX:NonNMethodCodeHeapSize=256M
-XX:ProfiledCodeHeapSize=256M
-XX:NonProfiledCodeHeapSize=256M
-XX:ReservedCodeCacheSize=768M

Whats the reason for this and how can I fix it?

skybber commented 1 month ago

It was already reported by @kademlia

https://youtrack.jetbrains.com/issue/JBR-7351/JVM-CodeCache-will-not-be-cleaned-using-G1GC-if-Hotswap-Agent-is-enabled-since-JBR-6419-jbr21.351

The fix is in the jbr21 branch and will be, hopefully, included in the next jbr21 release. Regarding the slowness of JBR21, this could occur because class loaders are checked for new classes iteratively now. This process might be more noticeable in applications with a lot of classes (tens/hundreds of thousands of classes).

NikitkoCent commented 1 month ago

@copyandexecute, just in case, which exactly build and which exactly link did you use to get the JBR 21 build?

copyandexecute commented 1 month ago

@skybber Thanks a lot for the fast reply, good to know <3 this issue can be closed

copyandexecute commented 1 month ago

@NikitkoCent I use this one https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-21.0.3-windows-x64-b509.4.tar.gz

Kademlia commented 1 month ago

@copyandexecute You can test the last release without the change: https://github.com/JetBrains/JetBrainsRuntime/releases/tag/jbr-release-21.0.2b346.3

Increasing the CacheSizes will make hotswapping slower in general. Using the default should be faster than providing the increased values. Going lower might even improve the speed while debugging (for example -XX:-SegmentedCodeCache -XX:ReservedCodeCacheSize=96m) .