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

    arkdengal

    I really have to thank you guys, thanks to this thread I got my server running so smooth its like ice skating.
    I really think there should be a guide put on the wiki using this info.
    You guys are awesome XD
     
    Phaedrus likes this.
  2. Offline

    Staartvin

    Hi everyone, I've been reading these pages and don't understand much out of them. I get some parts, but don't know what to do.. I have my own minecraft server with mcmyadmin. It has it Intel Core i7 2600 - 3,4GHz, 2 TB HDD, 8GB of RAM, Windows Home Premium 64 bits. It's connected via an ethernet cable with my router, which gives him 1Gbps. I've located 4Gb to mcmyadmin. But it lags with 5 people on it? Though it says it uses 1% of the computer? Hope you can help me?
     
  3. Offline

    Phaedrus

    It's been a while since I've helped someone with setting up MCMyAdmin, but I believe there is a section in the config that allows you to choose a different garbage collector style. The one you want is concurrent. Just changing that will be helpful. There should also be a way to pass your own arguments through MCMyAdmin to java by adding the commands to a line in the config. I suggest getting more familiar with the MCMyAdmin documentation.
     
  4. Offline

    fread2281

    see http://www.stefankrause.net/wp/?p=14
    I would recommend G1 since its the new gc and made to replace CMS (the one recommended).
    It also has the added bonus of releasing memory to the OS.
     
    Phaedrus likes this.
  5. Offline

    Phaedrus

    G1 is the way of the future no doubt. I haven't committed to Java 7 yet as I'm still testing it and giving it some more to mature. The performance of G1 is still only on par with the CMS collector, and freeing memory to the OS can still be achieved by simply restarting the server on a schedule, which should probably be done anyway.

    Thanks for the link to that article btw. Very nice to see.
     
  6. Offline

    Staartvin

    I use Java 7 on that server, how could I use this kind 'mode' of Garbage Collection?
     
  7. Offline

    Phaedrus

  8. Offline

    fread2281

    Server: 8GB RAM, AMD Athlon II X3 450

    My start.sh:
    Code:
    #craftbukkit filename
    craftbukkit="CraftBukkit.jar"
    #go to the dir that the script is in
    cd -P "$( dirname "${BASH_SOURCE[0]}" )"
    java -server -Xmx4G \
            -XX:MaxPermSize=256M \
            -XX:+UnlockExperimentalVMOptions \
            -XX:+UseG1GC \
              -XX:+DisableExplicitGC \
              -XX:MaxGCPauseMillis=50 \
              -XX:+UseAdaptiveGCBoundary \
              -XX:-UseGCOverheadLimit \
              -XX:SurvivorRatio=8 \
              -XX:TargetSurvivorRatio=90 \
              -XX:MaxTenuringThreshold=15 \
            -XX:+UseNUMA \
            -XX:+UseBiasedLocking \
            -XX:+DisableExplicitGC \
            -XX:+UseStringCache \
            -XX:+UseCompressedOops \
            -XX:+OptimizeStringConcat \
            -XX:+UseFastAccessorMethods \
            -XX:+AggressiveOpts \
            -jar $craftbukkit
    My two main questions are: Is there anything here that only applies to CMS/ParNew? and Are there any args I should be using for G1?

    I will probably do ramdisk and large pages soon.

    EDIT: Is "-XX:+UseAdaptiveGCBoundary" (or something better than it) already in G1? Seems like it to me from that page.
     
  9. Offline

    housemaster

    What settings can I try with 12gb ram and an i7 950? Using java 7 and windows server 2008 r2.
    currently I'm using http://pastebin.com/Ac4y6TPV (thanks to Phaedrus) with -Xmx 10gb, but I don't know if there's something that can be optimised, or changed for java 7, like the new garbage collection, and I have no idea what to change or how any of this works.
     
  10. Offline

    Phaedrus

    So far performance claims have been pretty tame, and should be no better or worse than simply using the command line I outlined previously. But if you'd like to do your own testing, See here for details on the new garbage collector: http://www.oracle.com/technetwork/java/javase/tech/g1-intro-jsp-135488.html
     
    housemaster likes this.
  11. Offline

    housemaster


    There appears to be a problem with the settings I use (http://pastebin.com/Ac4y6TPV), it ends up using this much RAM: http://i.imgur.com/LaIIQ.png and it doesn't lower with players, this was with 20~ players on. Also it goes well beyond the 10 Gb I set. Is there anything wrong in my settings, or does something in the settings not work with java 7 or windows server 2008?
     
  12. Offline

    Phaedrus

    I'm behind a security firewall so I can't see your imgur picture, but I can't see anything wrong with your settings offhand. Try installing Java 6 to a separate directory and modify your start line to point to the java 6 exe to test if it's a java 7 issue.
     
  13. Offline

    Staartvin

    I have another question (thanks for solving the other one

    How should my start.sh look like (of mcmyadmin) for the best performance?
     
  14. Offline

    GmK

    start.sh is only used to start "mono McMyAdmin.exe" - nothing else should be in there.
     
  15. Offline

    Staartvin

    ok. Anything else I can change which increases my performance?
     
  16. Offline

    Miles_

    I've been reading through this thread and it seems everyone is using windows, I host a server with a tiny 1.5 GB of ram and 2 Ghz single core processor, it's inning Ubuntu 10.10 (it doesn't support latest edition) and I start with a script using the xmx at 1200 and xms 1200 it seems to hold up fine with about 5 people and won't max out its ram until after about 20 minutes. It does often complain Utah overloaded but when t does it's usually no utilizing all the ram it's running on an old computet I found in my attic which I just had to switch the hard drive out for it to run. I don't understand how these servers with 8GB or so of ram are having issues but mine isn't (usually) I don't experience an lag but others sometimes say they do but I think it's just their computer, it does occasinally disconnect everyone for no reason and I have I restart sometimes. I also noticed people made a lot of changes to the startup script is there any sort of wiki explaining them? I am running ptweaks and nolagg bukkit pluins which help a ton. It used to restart every 30 mins but that got way to annoying so I changed it to 2 hrs and it has way more issues. Just 5 mins ago I did decrease it to 1 hr. and does restarting the computer help at all?

    Also does anyone know of a way to see the individual ram usages of the different server processe like how much a certain plugins is using or how much is allocated for loaded chunks/loading chunks/ generating new chunks and btw my server is strtkng to use the swap space

    If someone does reply that would help a lot rspecially since I'm working on a tutorial on setting up a server and it would be great I include this information

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

    DarkMein

    I have a server whith:
    Intel core I5
    16Gb RAM
    100 Mbps

    I have installed java 6, i will update in minecraft 1.2 to java 1.7.
    When i start my server i have several spam of GC, i cant deactivate the spam...
    Y use the RemoteToolKit to init my server:

    This is my command line:
    java -jar -Xms1024M -Xmx15000M -Djline.terminal\=jline.UnsupportedTerminal -XX\:+UseStringCache -XX\:+UseCompressedStrings -XX\:+UseCompressedOops -XX\:+OptimizeStringConcat -XX\:+UseFastAccessorMethods -XX\:+UseLargePages -XX:MaxGCPauseMillis=50 -XX:UseSSE=3 -XX\:parallelGCThreads\=4 -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+UseNUMA -XX:+CMSP -XX:+AggressiveOpts -Xloggc:gc.log craftbukkit.jar

    One cpu core its over 100%!!! I exec the command "top -s" to see this and i see a 150%-170% cpu usage... the TPS decrease whith 45 users.
    Im reduced the ram usage whith 50-60 users to 6Gb, before this optimizations i was using 11Gb.
    Any suggestion? The GC spam my console...


    Question 2. My priority is reduce the cpu usage, what happens if i run the server map in a ramdisk...?

    Sorry for my english, im spanish, i undertand english but im not very well writing.
     
  18. Offline

    arkdengal

    At first the server was running great but now im getting massive cpu usage that is causing lag
    java 6, centos 6, 1G ramdisk (large world) 3.2 Ghz quad core, 12G memory

    Code:
    java -server \
        -Xmx10G \
            -XX:SurvivorRatio=8 \
            -XX:TargetSurvivorRatio=90 \
            -XX:+AggressiveOpts \
            -XX:MaxGCPauseMillis=50 \
            -XX:+UseAdaptiveGCBoundary \
        -XX:PermSize=128m \
        -XX:MaxPermSize=256m \
        -XX:+DisableExplicitGC \
        -XX:+UseConcMarkSweepGC \
        -XX:+UseParNewGC \
        -XX:+CMSParallelRemarkEnabled\
        -XX:ParallelGCThreads=3 \
        -XX:UseSSE=3 \
            -XX:+UseBiasedLocking \
            -XX:+UseFastAccessorMethods \
            -XX:+OptimizeStringConcat \
        -XX:+UseStringCache \
            -jar craftbukkit.jar"
    
    im not using largepages because it requires set-up for my server. I also cannot use compressed strings.
    i read earlier phaedrus said to remove cpu flags but am unsure which exactly he meant.
    My server is growing very quickly, so i need to get this sorted out as soon as possible.
    also, what is bukkit++? i tried googling it real quick but didnt see results.

    Thanks!

    and any other suggestions are welcome!
     
  19. Offline

    DarkMein

    arkdengal: Minecraft/bukkit uses only one core, it isnt a multicore process...
    I have 1 core at 100%... when i have 50-60 players it is overloaded and the TPS decrease.


    I think that i could active the turboboost to increase the velocity of the minecraft core and decrease the velocity of the other 3 cores... we need bukkit whith multicore support or a computer whith Sandy Bridge.

    I have a Intel Core I5, it can use Turboboost.
     
  20. Offline

    arkdengal

    im not sure your catching me, before i added the extra GC coding i was using maybe 30% of my cpu w/ 6-10 players. I wanted to improve the performance of the server so i added the GC code above. then all of a sudden i was getting massive cpu spikes that showed 1200% the server max is 400%.... obviously i removed the code but i still want to improve performance, so i need help establishing which statement could be causing those spikes. i have been slowly changing the GC but its slow going since i only get to change it on restarts and im making one change at a time :(
     
  21. Offline

    Phaedrus

    Try removing this:
    Code:
    -XX:ParallelGCThreads=3
    And try reducing the -xmx size by a few gigs.
     
  22. Offline

    arkdengal

    ok i changed it to this, should look familiar.
    my server just seems to hate java.
    java -server \
    -Xmx5G \
    -XX:permSize=128m \
    -XX:MaxPermSize=256m \
    -XX:+DisableExplicitGC \
    -XX:+UseConcMarkSweepGC \
    -XX:+UseParNewGC \
    -XX:+UseNUMA \
    -XX:+CMSParallelRemarkEnabled \
    -XX:MaxGCPauseMillis=50 \
    -XX:+UseAdaptiveGCBoundary \
    -XX:-UseGCOverheadLimit \
    -XX:+UseBiasedLocking \
    -XX:SurvivorRatio=8 \
    -XX:TargetSurvivorRatio=90 \
    -XX:MaxTenuringThreshold=15 \
    -XX:UseSSE=3 \
    -XX:+UseFastAccessorMethods \
    -XX:+UseStringCache \
    -XX:+UseCompressedOops \
    -XX:+OptimizeStringConcat \
    -XX:+AggressiveOpts \
    -jar craftbukkit.jar nogui"

    my problem is, java isnt efficient enough as is ( lag :() and every time i try to change the flags to make it better, everything just seems to get worse. At this point im desperate enough to pay someone to fix this.
     
  23. Offline

    Phaedrus

    I think you need to start to look into other things like plugins. Your Java collector is as tuned as it is going to get and the problems you describe are far beyond what you'd see with garbage collection pauses.
     
    arkdengal likes this.
  24. Offline

    arkdengal

    in that case what kind of plugin would be the most likely to cause the cpu to push 3% or 150% and lag everyone out? and why does it get worse when the GC changes? some thing like MV-core? im gonna try and remove skylandsplus first, see if that makes any diff.

    edit: better idea, is there a way to monitor the usage of each plugin?
     
  25. Offline

    Phaedrus

    Your best bet might be to start a new thread and describe your problem in detail with your entire setup.
     
  26. Offline

    arkdengal

    thank you for your help :)
     
  27. Offline

    ray73864

    So i did some of the things found in this topic for our server, to see if i could improve it a bit and this is what i have:

    Code:
    nice --10 java \
            -d64 \
            -server \
            -Xmx16G \
            -verbose:gc \
            -Xloggc:/mnt/minecraft/craftbukkit/gc`date +%F`.log \
            -XX:+PrintGCTimeStamps \
            -XX:+PrintGCDetails \
            -XX:+PrintHeapAtGC \
            -XX:ParallelGCThreads=4 \
            -XX:PermSize=128m \
            -XX:MaxPermSize=256m \
            -XX:+DisableExplicitGC \
            -XX:+UseConcMarkSweepGC \
            -XX:+UseParNewGC \
            -XX:+UseNUMA \
            -XX:+CMSParallelRemarkEnabled \
            -XX:MaxGCPauseMillis=50 \
            -XX:+UseAdaptiveGCBoundary \
            -XX:-UseGCOverheadLimit \
            -XX:+UseBiasedLocking \
            -XX:SurvivorRatio=8 \
            -XX:TargetSurvivorRatio=90 \
            -XX:MaxTenuringThreshold=15 \
            -XX:UseSSE=3 \
            -XX:+UseFastAccessorMethods \
            -XX:+UseStringCache \
            -XX:+UseCompressedOops \
            -XX:+OptimizeStringConcat \
            -XX:+AggressiveOpts \
            -Xnoclassgc \
            -jar craftbukkit.jar
    
    The 'nice --10' is there to make Java been a mean bugger and not let anything else have so much free time with the CPU.

    Our system specs are:

    Core i7 950 w/ HT
    24GB RAM (16GB we've told minecraft it can go up to)
    10TB Bandwidth
    2x750GB SATA in RAID1

    OS: Linux (Debian x64 - latest version)

    *** Forgot to mention, running Java 1.7

    Minecraft sits in a 10GB RAMDrive of which we are using maybe 3GB of, we had issues with Dynmap so all the tiles for that were moved onto the HDD itself.

    With 16 players on, all doing stuff with either redstone or just in general SMP or playing a new 'Pitfrenzy' game that one of our youtube VIP's made, we continously get "Can't keep up!" on the console screen.

    The GC log is available at "http://www.mcaddictgallery.info/gc2012-03-13.log".

    I ran it through 'IBM Pattern Modeling and Analysis Tool for Java Garbage Collector' but naturally i don't fully understand it.

    The output from that is:

    Code:
    File name :  C:\Users\Ray\Downloads\gc2012-03-13.log
    Number of verboseGC cycles : 4
    Number of all Garbage Collections : 29,879
    Number of Full Garbage Collections : 0
    Number of Minor Garbage Collections : 29,879
    First Garbage Collection : Thu Jan 1 08:00:01 1970 (There's no startup timestamp information. The timestamp at View->Option->Start time is used.)
    Last Garbage Collection : Fri Jan 2 03:46:27 1970 (There's no startup timestamp information. The timestamp at View->Option->Start time is used to calculate last garbage collection time.)
    Maximum size of New generation : 348,913,664 bytes
    Maximum size of Tenured generation : 16,830,955,520 bytes
    Maximum size of Permanent generation : 268,435,456 bytes
    Overall Garbage Collection overhead : 0.34%
    Total time spent in non Garbage Collection : 70,945 seconds
    Maximum Garbage Collection overhead : 150% (Thu Jan 1 17:19:44 1970)
    Number of 100% overhead : 54
    Total Garbage Collection pause : 240 seconds
    Maximum Permanent Generation usage : 134,217,728 bytes ( 50% Thu Jan 1 08:00:00 1970)
    Average Permanent Generation usage : 31,573,967 bytes
    Maximum Tenured Generation usage : 1,152,674,816 bytes ( 6% Fri Jan 2 03:30:45 1970 )
    Average Tenured Generation usage : 556,549,894 bytes
    Maximum New Generation usage : 118,751,232 bytes ( 34% Thu Jan 1 08:00:01 1970 )
    Average New Generation usage : 114,238,133 bytes
    
     
  28. Offline

    Nightfear

    Hi, I have a server with so sett:
    CPU AMD 2.7Hz 6-core
    16Gb RAM,
    Debian 6.0

    And server is lagging when online going up to 45+.

    My *.sh

    java -server -d64 -Xmx15G -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+UseNUMA -XX:+CMSParallelRemarkEnabled -XX:MaxGCPauseMillis=50 -XX:+UseAdaptiveGCBoundary -XX:-UseGCOverheadLimit -XX:+UseBiasedLocking -XX:SurvivorRatio=8 -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=15 -XX:UseSSE=3 -XX:+UseLargePages -XX:+UseFastAccessorMethods -XX:+UseStringCache -XX:+UseCompressedStrings -XX:+UseCompressedOops -XX:+OptimizeStringConcat -XX:+AggressiveOpts -jar starter.jar nogui


    What I need to clear from this start-code?
     
  29. Offline

    Nightfear

  30. Offline

    andrewpo

    I'm surprised it runs bukkit at all with a 6 bit processor.
     
    Hankscorpiouk and Darky1126 like this.
Thread Status:
Not open for further replies.

Share This Page