How can I optimize Java on my server?

Discussion in 'Bukkit Help' started by odielag, Feb 10, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Phaedrus

    Try logging in as administrator if you aren't already.
    Make sure the craftbukkit jar file is named the same as in the batch file.
     
  2. Offline

    JohnEBH

    I am administrator.
    I've tried running as admin by right clicking, it gives me the Unable to access jarfile error.
    Yes the craftbukkit jar file is named the same in the batch. I tried it both ways
    Jar name: craftbukkit-0.0.1-SNAPS HOT Batch: craftbukkit-0.0.1-SNAPS HOT.jar
    Jar name: craftbukkit Batch: craftbukkit
    When I read up on the posts on this thread, you mentioned creating a shortcut and running at as admin in the compatibility tab. It's greyed out for me, same with the batch itself.
     
  3. Offline

    Phaedrus

    i'm confused. if your bukkit jar named craftbukkit or craftbukkit-0.0.1-SNAPS HOT

    remove the space between snaps and hot
     
  4. Offline

    JohnEBH

    Jar file is named: craftbukkit-0.0.1-SNAPSHOT and it's also the same in the batch file
    Is it ok to leave this be?
     
  5. Offline

    vapid2323

    Ok so I attempted to run my server with the following but I started to get huge ammounts of the cant keep up messages.

    Ubuntu 10.10 Server
    i7 3.6Ghz
    Two SSD's in raid0
    Java7

    Code:
    -Djline.terminal=jline.UnsupportedTerminal -server -XX:PermSize=128m -XX:MaxPermSize=256m -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:ParallelGCThreads=3 -XX:MaxGCPauseMillis=5 -XX:+UseAdaptiveGCBoundary -XX:-UseGCOverheadLimit -XX:+UseBiasedLocking -XX:SurvivorRatio=8 -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=15 -Xnoclassgc -XX:UseSSE=3 -XX:+UseFastAccessorMethods -XX:+UseStringCache -XX:+UseCompressedStrings -XX:+OptimizeStringConcat -XX:+AggressiveOpts  -Xmx24576M -jar craftbukkit.jar nogui -d "yyyy-MM-dd HH:mm:ss"
     
  6. Offline

    Phaedrus

    Change -XX:MaxGCPauseMillis=5 to -XX:MaxGCPauseMillis=50
     
  7. Offline

    Kainzo

    So uh.... @Phaedrus
    -verbose:gc
    What exactly does that do - @Phaedrus?

    Here's my new and improved launch.sh - my specs are the same
    OS: Debian
    Java: 7 (latest)
    24Gb ram
    i7 980x (12 cores)
    Ramdisk / 1.5TB raid5

    Code:
    #!/bin/sh
    /usr/jdk1.7.0/bin/java \
    	 -server \
    	 -Xmx20G \
    	 -XX:PermSize=128m \
    	 -XX:MaxPermSize=256m \
    	 -XX:+DisableExplicitGC \
    	 -XX:+UseConcMarkSweepGC \
    	 -XX:+UseParNewGC \
    	 -XX:+CMSParallelRemarkEnabled\
    	 -XX:ParallelGCThreads=3 \
    	 -XX:UseSSE=3 \
            -jar bmod.jar
    We see some large pauses / skips with 80+ players ... not to mention a lot of latency.
    Thoughts?
     
  8. Offline

    Phaedrus

    Verbose:gc spits out details on the garbage collections. Diagnostic purposes only.

    To cut down on the skips try upping the thread count to 4 and add -XX:MaxGCPauseMillis=50
    That will mean the longest pause for a gc will be about the same as 1 server tick.

    Lemme know if it helps.
     
  9. Offline

    Kainzo

    Wouldnt MaxGCPPause=50 be too short? - I feel that 50ms is very short for the amount of ram we have going and the map size
     
  10. Offline

    Phaedrus

    Not too short at all. It's also a guideline rather than a hard rule. It will try to keep each pause below that. If it can't clear everything it needs on each pass it will just do more passes. The important thing is that it's not pausing the main game thread for a noticeable amount of time.
     
  11. Offline

    Kainzo

    @Phaedrus I run a live server with over 90 players usually at a time, the map is 5000x5000 - having a bad "GC" flag can make or break a map - we've had map corruptions on some of them because of it. Running a server for almost the past year takes a toll on your brain at times...

    The bad part is - a different set of GC flags dont show right away and if it does corrupt things - we dont know until several hours later. What are the risks of lowering the MaxPauseGC?
     
  12. Offline

    Phaedrus

    I can't imagine how a java garbage collection can have any effect on world data. They are not related in any way. There are lots of other ways corruption could be introduced but I can't see gc being one of them.

    If you know something I don't, please explain.

    There is no real downside to limiting the pauses. Is your heap perpetually full? Are you running out of ram?
     
  13. Offline

    Kainzo

    It can easily corrupt world/map data. Setting values too high or too low can have varied results. ie xmx at 1G vs xms at 10G ... I'm sure could cause a bit of trouble.

    In either case
    Here's what I'm going to be testing next..

    #!/bin/sh
    /usr/jdk1.7.0/bin/java \
    -Xincgc \
    -Xmx20G \
    -XX:permSize=128m \
    -XX:MaxPermSize=256m \
    -XX:+DisableExplicitGC \
    -XX:+UseConcMarkSweepGC \
    -XX:+UseParNewGC \
    -XX:+CMSParallelRemarkEnabled\
    -XX:parallelGCThreads=4 \
    -verbose:gc \
    -XX:UseSSE=3 \
    -Xloggc:gc.log \
    -jar bmod.jar
     
  14. Offline

    Phaedrus

    If you're worried about corruption don't run java 7. It's pre pre release and seriously buggy. No need to be beta tester for sun in addition to notch and bukkit.
     
  15. Offline

    Kainzo

    You may be correct :p
    In either case we have both loaded onto the machine. I'm just worried about the slow downs and I feel that the majority are coming not from a hardware spec but more of a configuration issue.

    Here's the GC log btw - http://pastebin.com/9PHiSWZv
     
  16. Offline

    Phaedrus

    Im on the road at the moment. I'll check it out later.

    Plugin list?
     
  17. Offline

    Kainzo

    WG report (with plugin list) - http://pastebin.com/cJGaSMep

    @Phaedrus - let me know if you would like a more thorough report / GC log - I have more ;)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 8, 2016
  18. Offline

    PikoZain

    You need to remember that the bigger your java heap, the longer it will take to clean up that garbage.

    Remove xingc, set xms800m.
    For -XX:parallelGCThreads use 10 or 11, as the formula is this -XX:parallelGCThreads=<#cpus < 8 ? #cpus : 3 + ((5 * #cpus) / 8) >.
    Change back to jre6, no reason for you to be on 7 if it's not even stable yet.
    Just use -XX:MaxGCPauseMillis=500 or 2000 or 5000 if it bothers you so much, it's more of a goal then forcing it do it, 1000 milliseconds is just 1 second, so don't be afraid of a small pause.
    -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -verbose:gc -Xloggc:gc.log will give you a more detailed output of what your garbage cleaner is doing, suggest you use it.
    -XX:+UseCompressedStrings and -XX:+UseStringCache work extremely well.
    Also just let java take care of the boundaries of the heap with -XX:+UseAdaptiveGCBoundary
    You can also try something like -Xmn5g or half your current heap, and making it so that the young generation only moves objects to old when it's reached 90%.
    -XX:TargetSurvivorRatio=90
    This way you experience the 'UseParNewGC' a bit less, which is considered the full gc.
    I believe default is 50.
    The rest seems fine.
    If you can figure out how to configure largepages on linux, it should improve stability by 5-15%

    Goodluck, have fun experimenting :)
     
  19. Offline

    Kainzo

    -XX:+UseAdaptiveGCBoundary - with this - do you still need to set min/max for xmx and xms?

    also - what is xms2g ?
     
  20. Offline

    pomo4ka

    Explain to me please. If you say that the smaller the set the garbage collector, the faster it will clear it. So why put up to 20GB, etc? What is the difference then?
     
  21. Offline

    SteveMcGrath

    Here is my baskit config:

    Code:
    [Settings]
    environment = /opt/minecraft
    build = 860
    branch = stable
    memory = 1920
    flags = -server -d64 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:SurvivorRatio=16 -XX:+UseCompressedOops -XX:UseSSE=3 -XX:+UseAdaptiveGCBoundary -XX:MaxGCPauseMillis=500 -XX:ParallelGCThreads=3 -XX:+CMSIncrementalPacing -Djava.net.preferIPv4Stack=true -XX:NewRatio=3
    
     
  22. Offline

    PikoZain

    There's always a tradeoff . :)

    Most java applications always find their limit of memory suitable for them, however seeing as minecraft creates objects as it goes on (long lived), I can't say the same here.
    There's constantly things altering the world at the same time, it really is a ton to process.
    Personally for me, I don't run a minecraft server.
    I was having issues with one of the my server sided java applets, so I decided to do some research about pause time.
    So far I haven't encountered one, but this maybe because my applet was never that hungry in the first place.
    I currently have 1000 players online (on another game), not minecraft.
    Using java as well.
    It seems impossible to save much memory with minecraft, seeing as most of the world changes are probably considered long lived objects in java.
     
  23. Offline

    Kainzo

    Here's my new java launch - let me know if I should adjust anything...

    #!/bin/sh
    /usr/jdk1.7.0/bin/java \
    -Xmn5G \
    -Xmx12G \
    -Djline.terminal=jline.UnsupportedTerminal \
    -XX:MaxPermSize=256m \
    -XX:permSize=128m \
    -XX:TargetSurvivorRatio=90 \
    -XX:+DisableExplicitGC \
    -XX:+UseConcMarkSweepGC \
    -XX:+UseParNewGC \
    -XX:+CMSParallelRemarkEnabled\
    -XX:parallelGCThreads=8 \
    -XX:UseSSE=4 \
    -XX\:+UseCompressedOops \
    -XX:+UseCompressedStrings \
    -XX:+UseStringCache \
    -XX:+PrintGCDetails \
    -XX:+PrintGCTimeStamps \
    -XX:+PrintHeapAtGC \
    -verbose:gc \
    -Xloggc:gc.log \
    -jar bmod.jar

    With these flags I'm noticing a lot of Block lag right off the bat - with only 50-60 players... What could cause the hitches/hiccups?
     
  24. Offline

    Phaedrus

    Compressed oops
    8 threads may be too many. Try 6

    See my detailed post on page 2 to see how to set up a garbage collection grapher if you want some detailed info to work with.
     
  25. Offline

    Kainzo

    <font color="rgb(0, 0, 0)"><font color="rgb(34, 68, 34)"> </font><Edit by Moderator: Redacted mediafire url>

    <font color="rgb(0, 0, 0)">Full GClog</font>

    Heres my new "launch" ... going to give it a test and see if theres any immediate performance changes

    #!/bin/sh
    /usr/jdk1.7.0/bin/java \
    -Xmn4G \
    -Xms8G \
    -Xmx16G \
    -XX:SurvivorRatio=16 \
    -XX:TargetSurvivorRatio=90 \
    -XX:MaxGCPauseMillis=500 \
    -Djline.terminal=jline.UnsupportedTerminal \
    -XX:+UseAdaptiveGCBoundary \
    -XX:permSize=128m \
    -XX:MaxPermSize=256m \
    -XX:+DisableExplicitGC \
    -XX:+UseConcMarkSweepGC \
    -XX:+UseParNewGC \
    -XX:+CMSParallelRemarkEnabled\
    -XX:parallelGCThreads=5 \
    -XX:UseSSE=3 \
    -XX:+UseCompressedStrings \
    -XX:+UseStringCache \
    -XX:+PrintGCDetails \
    -XX:+PrintGCTimeStamps \
    -XX:+PrintHeapAtGC \
    -verbose:gc \
    -Xloggc:gc.log \
    -jar bmod.jar

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Dec 15, 2016
  26. Offline

    Phaedrus

    Try it without the gc logging too. I noticed some lag when I was using detailed logging.
    Also try with a max pause of 50-100
     
  27. Offline

    cuco

    What does "-server" do? Because with it, "svchost.exe" goes up to 50% CPU usage (1 full core of my dual core CPU) and the server takes about 3-5 seconds to respond.
    Without -server it seems to work fine

    My start script now:
    Code:
    @echo off
    "%ProgramFiles%\Java\jre6\bin\java.exe" -Djline.terminal=jline.UnsupportedTerminal -Xmn1G -Xms2G -Xmx3G -XX:PermSize=128m -XX:+UseConcMarkSweepGC -XX:ParallelGCThreads=2 -XX:+CMSParallelRemarkEnabled -XX:+DisableExplicitGC -XX:MaxGCPauseMillis=500 -XX:SurvivorRatio=16 -XX:TargetSurvivorRatio=90 -XX:+UseAdaptiveGCBoundary -XX:-UseGCOverheadLimit -Xnoclassgc -XX:UseSSE=3 -XX:+UseLargePages -jar craftbukkit-0.0.1-SNAPSHOT.jar
    pause
    Error at starting:
    Code:
    Java HotSpot(TM) 64-Bit Server VM warning: JVM cannot use larg
    use it does not have enough privilege to lock pages in memory.
    Starting the batch-script with admin rights doesn't change this error.

    Server has a Core2Duo E8400 (2 real cores with 3Ghz, 4 HT cores) and 8GB DDR2-800 RAM. But I need some RAM for ohter things so Bukkit should use never more than about 3,5-4GB.

    Running Windows Server 2008 R2 Datacenter.

    Anything to optimize here?

    Should I use Java 7?

    Greets
     
  28. Offline

    JohnEBH

    I'm trying out McMyAdmin and I'm thinking of putting these settings in, but I'm not sure which parts I should be putting into the "javaopts=" line because i also see right above it Garbage Collection mode options which are currently on default. Could someone advise?
     
  29. Offline

    Geracl

    how best to run the server with these characteristics
    AMD Athlon x64 x2 Dual 2.41
    7.96 GB of RAM
    Now run this:
    screen-A-h 1500-m-d-S mc java-Xmx2048M-Xms64M-jar craftbukkit.jar leg
    If the increase above Xmx2048M 2d, the server will not start. Help me to run a server on the 5G ram. Sorry for my english

    (russian)
     
  30. Offline

    Phaedrus

    -server changes some variables in favour of server work loads. If you're using 64-bit java and your system has enough ram, chances are -server will be used by default.

    looks ok, but here's a few things you might want to try:
    - I'd remove xmn and xms entirely and let java make the adjustments as needed. leave xmx as the max
    - try reducing the max pause time to 50ms, 500 is actually quite a long time in relation to garbage collections
    - try with and without the survivor ratio changes to see if it makes a difference for you

    Are you actually logged in as an administrator? or just running the batch file AS an administrator?
    Why are you using server 2008 R2 Datacenter? Standard would be far more appropriate.

    I wouldn't recommend it. At best, performance would be equal to java 6. it's still got a lot of bugs. wait until an official release.

    anything you put in javaopts will over ride the garbage collection options above it. If you aren't comfortable with messign with it, just change the garbage collection option to consequtive mode.

    Is your OS 64-bit?

    try -xmx 5g

    Ok, I finally got around to looking at your gc log.

    Try this line:

    Code:
    -server
    -Xmx16G
    -XX:PermSize=128m
    -XX:MaxPermSize=256m
    -XX:+DisableExplicitGC
    -XX:+UseConcMarkSweepGC
    -XX:+UseParNewGC
    -XX:+CMSParallelRemarkEnabled
    -XX:ParallelGCThreads=6
    -XX:MaxGCPauseMillis=15
    -XX:+UseAdaptiveGCBoundary
    -XX:-UseGCOverheadLimit
    -XX:+UseBiasedLocking
    -XX:SurvivorRatio=8
    -XX:TargetSurvivorRatio=90
    -XX:MaxTenuringThreshold=15
    -Xnoclassgc
    -XX:UseSSE=3
    -XX:+UseLargePages
    -XX:+UseFastAccessorMethods
    -XX:+UseStringCache
    -XX:+UseCompressedStrings
    -XX:+OptimizeStringConcat
    -XX:+AggressiveOpts
    
    The great majority of your garbage collections are between 10 and 20ms already, so I've specified a max pause time of 15ms which might help keep stutters down. Experiment with lowering it even further to 10ms.

    I've only defined the max heap size, and allow java to control generational heaps as needed, with the guidance to favour the young generation objects so that they have more time to die, rather than being promoted to the old generation.

    This is very close to what I run with using very similar hardware and have found gives the best performance. I don't have 50+ users though, so your milage may vary.

    Lemme know if you notice any difference.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 8, 2016
Thread Status:
Not open for further replies.

Share This Page