endofzero / Minecraft-Sheller

Shell script designed to allow for automation of Minecraft Server Administration.
62 stars 18 forks source link

Additional Java flags to use for starting the servers #1

Closed endofzero closed 13 years ago

endofzero commented 13 years ago

Which of these options should be considered to be viable for all installations... single and multi core?

Without getting into technical details, you can use the following two flags that should increase your server's performance:

  -XX:+UseConcMarkSweepGC -XX:+UseParNewGC

Applied to your entire command line, it may look like this:

java -server -Xmx1024M -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -jar minecraft_server.jar nogui

ricin has also suggested using the following flags:

Code: Select all -XX:+CMSIncrementalPacing -XX:ParallelGCThreads=2 -XX:+AggressiveOpts

Applied to your entire command line, it may look like this:

java -server -Xmx1024M -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSIncrementalPacing -XX:ParallelGCThreads=2 -XX:+AggressiveOpts -jar minecraft_server.jar nogui

The -server flag forces Java to use the "server JVM," which runs a bit more optimized than the regular client JVM. Your server may already run with the server flag -- it depends on your system's specifications.

Note that these flags will overall consume more CPU and memory, but your Minecraft server will run better on the other hand.

RESEARCH: http://www.minecraftforum.net/viewtopic.php?f=1012&t=68128

http://www.petefreitag.com/articles/gctuning/

http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html

-XX:+AggressiveOpts

Turns on point performance optimizations that are expected to be on by default in upcoming releases. The changes grouped by this flag are minor changes to JVM runtime compiled code and not distinct performance features (such as BiasedLocking and ParallelOldGC). This is a good flag to try the JVM engineering team's latest performance tweaks for upcoming releases. Note: this option is experimental! The specific optimizations enabled by this option can change from release to release and even build to build. You should reevaluate the effects of this option with prior to deploying a new release of Java.

endofzero commented 13 years ago
if -XX:+UseConcMarkSweepGC is used on the command line then the flag UseParNewGC is also set to true if it is not otherwise explicitly set on the command line

So the answer is you only need to use -XX:+UseConcMarkSweepGC and it will enable the concurrent collector with the parallel young generation collector.

Edit: for Java 6, the same flag (-XX:+UseConcMarkSweepGC) enables the concurrent collector. The choice of collector you want depends on a few things, and you should test different configurations. But there are some very general guidelines. If you have a single processor, single thread machine then you should use the serial collector (default for some configurations, can be enabled explicitly for with -XX:+UseSerialGC). For multiprocessor machines where your workload is basically CPU bound, use the parallel collector. This is enabled by default if you use the -server flag, or you can enable it explicitly with -XX:+UseParallelGC. If you'd rather keep the GC pauses shorter at the expense of using more total CPU time for GC, and you have more than one CPU, you can use the concurrent collector (-XX:+UseConcMarkSweepGC). Note that the concurrent collector tends to require more RAM allocated to the JVM than the serial or parallel collectors for a given workload because some memory fragmentation can occur.

endofzero commented 13 years ago

To solve this, I will just do what I did with the cartography and overview options. Move them to the beginning in the form of a config setting. This allows the user to easily control the java behavior based on what they need.

endofzero commented 13 years ago

This has been added and is now in the process of being tested.