Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Hey, sorry for the late reply. A few important notes before you read/copy the flags:
- Make sure to use GraalVM with this set of flags.
- Please keep in mind that I am not professional developer and I have limited experience with programming in C, Java, and Javascript. The product of this set of flags was from several months of research and reasoning and testing using JFR in Minecraft and analysis using VisualVM. Feel free to do your own testing and change whatever you want if you absolutely know what you are doing. Of course this set isn't perfect but it should not cause issues on decently fast PCs with enough RAM.
- - You must use JDK 21 or later to use these flags
- - The flag "-XX:+UseGraalJIT" only works on JDK 23+ but does cause issues in earlier versions
- - If you are going to measure performance using JFR in Minecraft you should disable "UseFastUnorderedTimeStamps" and "PerfDisableSharedMem" by changing the + to a - for both to get more accurate data.
- - Your PC should have at least 16 GB of RAM for these flags to work properly.
- - The only flags that are okay to change as needed are "UseStringDeduplication" if RAM is a concern and if your CPU is fast enough although you don't usually need to do this and you should not resort to it either, "AllocatePrefetchStyle" with 1 if 3 does not work, and "Djdk.graal.CompilerConfiguration" to 'community' if 'enterprise' is causing inconsistent or poor performance.
- Some special notes for some flags:
- - You may enable "UseLargePages" using + instead of - only if it is enabled on your PC admin account. If you are not technical enough change permissions to use large pages on your PC admin account, then I advise against using it.
- - If you know how to follow instructions properly and not mess up your PC I can link the article on how to allow large pages on your admin account. If you try to enable large pages using + without the proper permissions it will not work. And, NEVER launch Minecraft as an admin to use large pages unless you absolutely need to for a good reason that is not for playing the game.
- - You may remove "Xlog:gc+init" and "PrintCodeCache" if you do not want to see that information in the minecraft log with every startup.
- - DO NOT change the flags AFTER "Dfile.Encoding=UTF-8". Those are at their default values except I think "UseFastStosb", but I have them there for future reference and use in testing. Unless you know what they are and what you are doing do not touch those and do not remove them.
- **Some** of the main sources of my research are listed below:
- - https://github.com/brucethemoose/Minecraft-Performance-Flags-Benchmarks (Slightly outdated but still relevant)
- - https://github.com/Mukul1127/Minecraft-Performance-Flags-Benchmarks/tree/main (Has more recent information but with some inaccuracies)
- - https://chriswhocodes.com/ (Used to see the description of what certain JVM flags do)
- I also used the "-XX:+PrintFlagsFinal" and "-XX:+JVMCIPrintProperties" flags to show the default and current settings of all flags for the JVM and JVMCI properties to the Graal JIT options.
- If you have any questions feel free to in the reddit thread or message me via PM on reddit.
- Keep Xmx and Xms at the same size. 4G should be good for Vanilla up to 16 chunk render distance and 8 to 10 chunk simulation. I recommend 6G or 8G for modded/shaders with the same render and simulation. And, up to 12G for heavily modded instances (maybe like 200+ mods depending on what mods are used). Don't forget to remove Xmx and Xms if you are using MultiMC. ZGC is not negatively affected by increasing allocated memory, however it is ideal to use what your MC instance only needs with a considerably small margin in place.
- I also recommend using Large pages for hosted servers and not for regular single player games because large pages causes memory fragmentation, if you keep starting Minecraft with this option you may not be able to launch the VM because it will say that you need to use less memory. This is because the RAM is too fragmented and the only way to fix this is by restarting your PC. Memory fragmentation is not harmful to your data or computer but it may not allow you to launch programs at a certain point. If you leave a program using large pages running and do not quit it, it will work properly for a long time. I don't think doing that will cause issues with fragmentation although I haven't thoroughly looked into this.
- -Xmx4G -Xms4G -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+UseGraalJIT -XX:+EagerJVMCI -XX:+DisableExplicitGC -XX:-UseStringDeduplication -XX:+AlwaysPreTouch -XX:+AlwaysPreTouchStacks -XX:-DontCompileHugeMethods -XX:+PerfDisableSharedMem -XX:+UseFastUnorderedTimeStamps -XX:+AlwaysCompileLoopMethods -XX:-UseCriticalJavaThreadPriority -XX:NmethodSweepActivity=1 -XX:ReservedCodeCacheSize=400M -XX:NonNMethodCodeHeapSize=12M -XX:ProfiledCodeHeapSize=194M -XX:NonProfiledCodeHeapSize=194M -XX:MaxNodeLimit=240000 -XX:NodeLimitFudgeFactor=6000 -XX:+UseZGC -XX:+ZGenerational -XX:AllocatePrefetchStyle=3 -Djdk.graal.CompilerConfiguration=enterprise -Djdk.graal.TuneInlinerExploration=1 -XX:-UseLargePages -XX:LargePageSizeInBytes=2M -Xlog:gc+init -Xlog:async -XX:+PrintCodeCache -Djava.security.egd=file:/dev/urandom -Dfile.Encoding=UTF-8 -XX:-UseFastStosb -XX:-UseVectorCmov -XX:-UseCMoveUnconditionally -XX:-AlignVector -XX:-UseVectorStubs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement