Skip to content

Instantly share code, notes, and snippets.

@TerrorBite
Created May 27, 2017 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TerrorBite/e343dd1b5b44ce5e52686f7d8fcc08bc to your computer and use it in GitHub Desktop.
Save TerrorBite/e343dd1b5b44ce5e52686f7d8fcc08bc to your computer and use it in GitHub Desktop.
java_opts="$java_opts -XX:MaxGCPauseMillis=50"
# Disable explicit GC. Some plugins may think it's a good idea to manually run the garbage collector.
# This is never a good idea with our setup, as it introduces a pause that is usually completely avoidable.
java_opts="$java_opts -XX:+DisableExplicitGC"
### OPTIMIZATION SETTINGS ###
# Bukkit and Spigot synchronize things for thread safety. Some of these synchronizations are never contested under ideal conditions.
# This option optimises those cases so that uncontested syncs become much cheaper.
java_opts="$java_opts -XX:+UseBiasedLocking"
# Turn on performance optimizations that are expected to be turned on by default in future versions of Java.
# This generally can't hurt, but comment it out if java.lang.UnsupportedOperationExceptions appear at startup.
java_opts="$java_opts -XX:+AggressiveOpts"
# Enable optimization of getter functions, an easy way to reduce some function overhead.
java_opts="$java_opts -XX:+UseFastAccessorMethods"
### MEMORY MANAGEMENT ###
# Enable HugePages support to improve memory access performance in the OS. We have 8GB of RAM dedicated to HugePages.
#java_opts="$java_opts -XX:+UseLargePages"
# Raise the maximum size of the Permanent Generation area (which stores class data, and static data like string literals)
# to 128MB (default is 64MB) so we don't run out of PermGen space. The CMSClassUnloading should help with this though.
# The PermGen space is GOING AWAY in Java 8, since this data will be stored in native memory instead ("Metaspace").
# The replacement option will be: -XX:MaxMetaspaceSize
#java_opts="$java_opts -XX:MaxPermSize=128m"
java_opts="$java_opts -XX:MaxMetaspaceSize=256m"
# Adjust the Target Survivor Ratio: This basically determines how full the GC is letting the Survivor generations get before
# moving things into the Old generation. By using a higher value we improve efficiency of memory use, but lose some "overhead"
# that would absorb allocation spikes. Default is 50%, our setting is 80%, some servers go as high as 90%.
java_opts="$java_opts -XX:TargetSurvivorRatio=80"
# I would love to adjust XX:SurvivorRatio, XX:MaxTenuringThreshold etc to suitable values, but http://i.imgur.com/ntELi.jpg
# I don't know what a Minecraft server's requirements are, though inspection through a profiler may reveal the details.
# Big eden, smaller survivor area. Minecraft tends to create large quantities of short-lived objects as part of its processing
# of game data, compared to a smaller amount of long-lived objects, so we want to prioritize the eden area of memory.
# NOTE: This is probably ignored because we didn't specify -XX:-UseAdaptiveSizePolicy
java_opts="$java_opts -XX:SurvivorRatio=10"
java_opts="$java_opts -classpath apache-log4j-2.8-bin"
### END OF JAVA OPTIONS ###
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment