wispborne / TriOS

Starsector mod manager & toolkit.
https://fractalsoftworks.com/forum/index.php?topic=29674.0
GNU General Public License v3.0
9 stars 1 forks source link

Feature: ZGC support on JVM 23 #60

Closed Dessix closed 1 month ago

Dessix commented 1 month ago

ZGC may offer some performance benefits over the G1GC. I've seen smoother gameplay and combat (albeit with some hiccups directly after loading quicksaves) while using ZGC with the following parameters:

-XX:+AlwaysPreTouch
-XX:+ParallelRefProcEnabled
-XX:ParallelGCThreads=6
-XX:+PerfDisableSharedMem
-XX:+UnlockExperimentalVMOptions
-XX:+DisableExplicitGC
-XX:+UseZGC
-Xms16384m
-Xmx16384m
-Xss2048k
-XX:PermSize=512m
-XX:MaxPermSize=512m

Note that these parameters are only supported on newer JVMs (e.g. JVM 23). Also note that the ZGC documentation recommends Xms and Xmx being the same size, while pretouch ensures that it's allocated ahead of time for lower latency.

Alternatively, custom vmparams from within the JVM selection menu might be viable, though there might need to be special handling for cancelling out existing parameters, because the existing VMParams come with -XX:+UseG1GC, which needs removed in order to activate ZGC. Perhaps just a textbox for extra VM params and a selector for choice of GC would be good enough?

wispborne commented 1 month ago

TriOS uses Himemi's Java 23, and simply launches one of the two .bat files included with it, so editing the Miko_R3.txt file directly will work.

Dessix commented 1 month ago

After attempting the same parameters via that file, I actually saw significant performance regressions; I suspect Miko may have benchmarked the GCs for comparison before publishing, but it was interesting to see that ZGC ran with more hiccups than Miko's selected ShenandoahGC, despite both having very similar architectures.

For performance-specifics, I think this can probably be closed, though there could be room for someone to collect hard numbers if they can devise a benchmark. Otherwise, the "automatically adding VMParams" bit for mods that require -XX:Verify:None and similar (e.g. AI Tweaks) could still be tracked by this issue or moved to a new one generalized to parameter handling.

wispborne commented 1 month ago

@Yumeris just CCing you in case this is interesting. I'm going to close this one.

My plan from the start has been to bury the Java 23 feature in the UI (or even remove it, depending) after the next Starsector patch releases with Java 17. The complexity and associated upkeep of it is probably not going to be worth it - hopefully there will be minimal performance difference between 17 and 23 and all but the most geeky can forget about changing JREs or tweaking vmparams.