Skip to content

Instantly share code, notes, and snippets.

@kuzetsa
Last active February 10, 2020 15:55
Show Gist options
  • Save kuzetsa/cdfeece0064db78d30b0 to your computer and use it in GitHub Desktop.
Save kuzetsa/cdfeece0064db78d30b0 to your computer and use it in GitHub Desktop.
JVM settings for minecraft - Revision #6
JvmArgs=-Djava.net.preferIPv4Stack=true -server -XX:+UnlockExperimentalVMOptions -XX:CompileThreshold=752253 -XX:+TieredCompilation -XX:+UseStringCache -XX:+OptimizeStringConcat -XX:+UseBiasedLocking -Xnoclassgc -XX:+UseFastAccessorMethods -XX:+UseCompressedOops -XX:+UseG1GC -XX:NewSize=624m -XX:MaxNewSize=624m -XX:MaxGCPauseMillis=5 -XX:G1HeapRegionSize=128k -XX:G1HeapWastePercent=8 -XX:InitiatingHeapOccupancyPercent=69 -XX:SurvivorRatio=71 -XX:TargetSurvivorRatio=85 -XX:MaxTenuringThreshold=6 -XX:MaxHeapFreeRatio=11 -XX:MinHeapFreeRatio=7 -XX:ParallelGCThreads=2 -XX:ConcGCThreads=1
@kuzetsa
Copy link
Author

kuzetsa commented May 24, 2015

This is commentary for the most up-to-date version (v6)

Java Arguments:
[-Djava.net.preferIPv4Stack=true, -server, -XX:+UnlockExperimentalVMOptions, -XX:CompileThreshold=752253, -XX:+TieredCompilation, -XX:+UseStringCache, -XX:+OptimizeStringConcat, -XX:+UseBiasedLocking, -Xnoclassgc, -XX:+UseFastAccessorMethods, -XX:+UseCompressedOops, -XX:+UseG1GC, -XX:NewSize=624m, -XX:MaxNewSize=624m, -XX:MaxGCPauseMillis=5, -XX:G1HeapRegionSize=128k, -XX:G1HeapWastePercent=8, -XX:InitiatingHeapOccupancyPercent=69, -XX:SurvivorRatio=71, -XX:TargetSurvivorRatio=85, -XX:MaxTenuringThreshold=6, -XX:MaxHeapFreeRatio=11, -XX:MinHeapFreeRatio=7, -XX:ParallelGCThreads=2, -XX:ConcGCThreads=1, -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump, -Xms2064m, -Xmx3333m, -XX:PermSize=304m, -Duser.language=en, -jar, C:/Clever_Minecraft_Things/MultiMC/jars/NewLaunch.jar]


   



   

Goals currently met:

  • Almost no freezing stuttering when teleporting to a new area.
  • No sudden drops in framerate
    (except when the "stop-the-world" garbage collections occur VERY RARE!!! ... really, it could be hours or even never, assuming you allocated enough ram.)
  • No memory-related crashes or gameplay issues. (Should only be the usual bugs which have nothing to do with any of these memory allocation / garbage collection settings.)
  • Plays smoother than unmodified / stock / vanilla / non-tweaking minecraft. (MUCH smoother!!!)

Note:

There are some specific things (which I was previously NOT doing) in G1 which are unrelated to how things work in some of the older garbage collectors...

Latest version of these settings throws tons of ram at the latency problems until the issues [mostly] go away. Example: eventually if you play for long enough, a full "stop-the-world" garbage collection could eventually occur. (orders of magnitude more likely if you're playing a modpack with hundreds of mods)


   



   

Resources:

@kuzetsa
Copy link
Author

kuzetsa commented Jul 4, 2015

OLDER VERSION (v5)

{obsolete settings}

Java Arguments:
[-Djava.net.preferIPv4Stack=true, -server, -XX:+UnlockExperimentalVMOptions, -XX:CompileThreshold=752253, -XX:+TieredCompilation, -XX:+UseStringCache, -XX:+OptimizeStringConcat, -XX:-UseBiasedLocking, -Xnoclassgc, -XX:+UseFastAccessorMethods, -XX:+UseCompressedOops, -XX:+UseG1GC, -XX:NewSize=384m, -XX:MaxNewSize=384m, -XX:MaxGCPauseMillis=5, -XX:G1HeapRegionSize=128k, -XX:G1HeapWastePercent=8, -XX:InitiatingHeapOccupancyPercent=69, -XX:SurvivorRatio=71, -XX:TargetSurvivorRatio=85, -XX:MaxTenuringThreshold=6, -XX:MaxHeapFreeRatio=31, -XX:MinHeapFreeRatio=29, -XX:ParallelGCThreads=31, -XX:ConcGCThreads=17, -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump, -Xms3333m, -Xmx3333m, -XX:PermSize=317m, -Duser.language=en, -jar, C:/Clever_Minecraft_Things/MultiMC/jars/NewLaunch.jar]

@kuzetsa
Copy link
Author

kuzetsa commented Jul 4, 2015

OLDER VERSION (v4)

{obsolete settings}

JvmArgs=-Djava.net.preferIPv4Stack=true -XX:+UseStringCache -XX:+OptimizeStringConcat -XX:NewSize=2g -XX:MaxNewSize=2g -XX:+UseG1GC -XX:CompileThreshold=1500 -XX:-TieredCompilation -XX:TargetSurvivorRatio=95 -XX:SurvivorRatio=5 -XX:MaxTenuringThreshold=15 -XX:+UnlockExperimentalVMOptions -XX:-UseBiasedLocking -Xnoclassgc -XX:+UseFastAccessorMethods -XX:+UseCompressedOops


   



   

Java Arguments:
[-Djava.net.preferIPv4Stack=true, -XX:+UseStringCache, -XX:+OptimizeStringConcat, -XX:NewSize=2g, -XX:MaxNewSize=2g, -XX:+UseG1GC, -XX:CompileThreshold=1500, -XX:-TieredCompilation, -XX:TargetSurvivorRatio=95, -XX:SurvivorRatio=5, -XX:MaxTenuringThreshold=15, -XX:+UnlockExperimentalVMOptions, -XX:-UseBiasedLocking, -Xnoclassgc, -XX:+UseFastAccessorMethods, -XX:+UseCompressedOops, -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump, -Xms4864m, -Xmx4864m, -XX:PermSize=512m, -Duser.language=en, -jar, C:/Clever_Minecraft_Things/MultiMC/jars/NewLaunch.jar]

There might be some kind hardcoded upper limit to MaxTenuringThreshold which causes any value larger than 15 to be treated as "infinity" and breaks things when this occurs...

Probably not an optimal design decision on the part of the JVM developers, but I'm not an expert on JVMs so not really going to discuss this specifically...

Learned some more info about how the ratios work, and how to better make use of the eden / survivor space...

I don't know how to explain it though, just know that I made some empirical observations and when I was researching I came across some jargon-heavy explanations about how it all works.

I wish I could say more without sounding like I'm fumbling around in the dark without a clue here, but that's pretty close to how it actually is so I'll just update this gist with v4 now O_O

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment