Mukul1127 / Minecraft-Performance-Flags-Benchmarks

Sane, Benchmarked Java Flags and Tweaks for Minecraft
https://github.com/Mukul1127/Minecraft-Java-Flags
MIT License
263 stars 5 forks source link

Need some advice #16

Closed QianFuv closed 3 months ago

QianFuv commented 3 months ago

These are the startup parameters I am currently using:

-XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+AlwaysActAsServerClassMachine -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:AllocatePrefetchStyle=3 -XX:NmethodSweepActivity=1 -XX:ReservedCodeCacheSize=400M -XX:NonNMethodCodeHeapSize=12M -XX:ProfiledCodeHeapSize=194M -XX:NonProfiledCodeHeapSize=194M -XX:-DontCompileHugeMethods -XX:+PerfDisableSharedMem -XX:+UseFastUnorderedTimeStamps -XX:+UseCriticalJavaThreadPriority -XX:+EagerJVMCI -Dgraal.TuneInlinerExploration=1 -XX:+UseG1GC -XX:MaxGCPauseMillis=37 -XX:+PerfDisableSharedMem -XX:G1HeapRegionSize=16M -XX:G1NewSizePercent=23 -XX:G1ReservePercent=20 -XX:SurvivorRatio=32 -XX:G1MixedGCCountTarget=3 -XX:G1HeapWastePercent=20 -XX:InitiatingHeapOccupancyPercent=10 -XX:G1RSetUpdatingPauseTimePercent=0 -XX:MaxTenuringThreshold=1 -XX:G1SATBBufferEnqueueingThresholdPercent=30 -XX:G1ConcMarkStepDurationMillis=5.0 -XX:GCTimeRatio=99

I'm using a 600+mod modpack, allocating 12GB of memory and using GraalvmJDK21. The memory usage is between 70% to 80%, which I believe is not an ideal state. Therefore, I decided to increase the allocated memory to 16GB. However, with the current startup parameters, it easily leads to crashes due to memory overflow. I think I need to modify some of these parameters in order to adapt them for the 16GB memory situation. Unfortunately, I am not well-versed in this area of knowledge, so I come here seeking assistance.šŸ„°I hope to receive some advice!

JL2210 commented 3 months ago

75% memory is fairly normal with large packs. The more memory you give Java, the more memory it will use. Then when it needs to garbage collect, it will use old generation pauses which cause stutter.

The original Aikar's Flags has flags for greater than 12GB if you absolutely need them,

QianFuv commented 3 months ago

I realize that there are some differences between the parameters of Aikar and those you provided. Can you give me some suggestions for modifying your parameters?

JL2210 commented 3 months ago

I just copied them from aikar.co in the 12GB+ section

https://aikar.co/2018/07/02/tuning-the-jvm-g1gc-garbage-collector-flags-for-minecraft "If you are using an Xmx value greater than 12G"

Mukul1127 commented 3 months ago

75% memory is fairly normal with large packs. The more memory you give Java, the more memory it will use. Then when it needs to garbage collect, it will use old generation pauses which cause stutter.

The original Aikar's Flags has flags for greater than 12GB if you absolutely need them,

* `-XX:G1NewSizePercent=40`

* `-XX:G1MaxNewSizePercent=50`

* `-XX:G1HeapRegionSize=16M`

* `-XX:G1ReservePercent=15`

* `-XX:InitiatingHeapOccupancyPercent=20`

* NOTICE: If you see increase in old generation collections after this, revert back to the base flags!

This seems like the best bet for increasing to 16 gb but also read this if you are using these flags for the client: https://github.com/Mukul1127/Minecraft-Performance-Flags-Benchmarks#client-g1gc