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


    Why make a new fork of CB rather then just make pulls to the actual CB project.

    CB++ apparently only works on 1.1 anyways.
  2. Offline


    There are obvious answers to this question, which I will let you explore and discover for yourself. ;)
  3. Offline


    i am using:
    START "MINECRAFT-CRAFTBUKKIT" /ABOVENORMAL /B "C:\Program Files\Java\jre64\bin\java.exe" -server -Xmx3G -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:+UseCompressedStrings -XX:+UseCompressedOops -XX:+OptimizeStringConcat -XX:+AggressiveOpts -jar "%~dp0craftbukkit-1.0.1.jar"

    i have 6 core AMD with 8gb ram dedicated serv win7 + ssd
    serv is Cant keeup on 50+ ppl
    and only 1Gb ram is using with 50+ ppl

    no erors in console, why server lags with 50+?
    plz help
  4. Offline


    Maybe because you're only allowing the server to use 3 gigs of ram?

  5. Offline


    but it use only 1gig, see screen plz
  6. Offline


    50 people might be too much for regular bukkit to handle. Try Bukkit ++ ?
  7. Offline


    cant, i need IC2+Build
  8. Offline


    What should I use with these specs?

    Intel® Core™ i7-990X Hexa Core 6x 3.47 GHz
    24 GB DDR3 RAM
    Eine 3 TB SATA 6 7200 rpm
    128 GB SSD Festplatte
    1 Gbit and unlimited Traffic

    Run on Windows Server 2008 RC2 (It's good for development. Later Linux or Debian)
    Bukkit, McMyAdmin

    I am using:
    -Xms9728M  -XX:+UseParallelGC  -XX:ParallelGCThreads=8 -XX:+UseAdaptiveSizePolicy -verbose:GC -Xmx9728M
  9. Offline


    Read my detailed post in page 2. It should help you craft a line to match your hardware.
  10. Offline


    Best thread ever! I can't believe how stupid my Linux start script was. I had obviously followed some bad advice in other threads (i've tried changing and researching options at least 5x) . xincgc was proably the worst suggestion I ever used.

    Easily gone from using 4gb ram to 1gb.

    Old start string was:
    java -D64 -server -Xmn512M -Xms2500M -Xmx8000M -XX:SurvivorRatio=16 -Xnoclassgc -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:parallelGCThreads=5 -XX:SurvivorRatio=16 -XX:+CMSIncrementalPacing -XX:UseSSE=3 -jar craftbukkit.jar nogui

    new one is:
    java -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+UseNUMA -XX:+CMSParallelRemarkEnabled -XX:MaxGCPauseMillis=50 -XX:+UseAdaptiveGCBoundary
    -XX:-UseGCOverheadLimit -XX:+UseBiasedLocking -XX:UseSSE=3 -XX:+UseLargePages -XX:+UseFastAccessorMethods -XX:+UseStringCache
    -XX:+UseCompressedStrings -XX:+UseCompressedOops -XX:+OptimizeStringConcat -XX:+AggressiveOpts
    -Xmx8G -jar craftbukkit.jar nogui

    I cannot believe how insane the difference is in memory and CPU usage even when 20 users are online.

    (Multiverse-Core also helped keep memory down by keeping unused chunks from being loaded, but changing the launch string made the biggest difference)

    Server is a Six Core AMD Phenom II X6 Thuban /w 16GB ram and dual 1.5tb HDD.
  11. Offline


    Anyone have any tweaks for my current hardware/startup line?

    CPU: Dual Intel Xeon L5420 (2 x 4 x 2.5GHz cores (8 total))
    Linux: CentOS 6.2
    Linux 2.6.32-220.4.1.el6.x86_64 #1 SMP Tue Jan 24 02:13:44 GMT 2012 x86_64 x86_64 x86_64 GNU/Linux
    java version "1.6.0_22"
    OpenJDK Runtime Environment (IcedTea6 1.10.4) (rhel-
    OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)
    Startup line: (ran via rkit)
    java -server -d64 -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\:+UseFastAccessorMethods -XX\:+AggressiveOpts -Djline.terminal\=jline.UnsupportedTerminal -jar craftbukkit.jar nogui
    The server works very well with this line so far, but I'm wondering if I should change anything.

    Using normal Craftbukkit, and around 30-40 plugins... I haven't had many players online, so I'm not too sure how well it'll function under heavier load, but it's pretty good so far.
  12. Offline


    Looks ok to me. Your java version looks like it might be out of date. I think java 6 is up to release 30 now...
  13. Offline


    Thanks, I'm just using the default ones.

    Should I go try to upgrade to JRE 7, or stick with 6?
  14. Offline


    Java 7 probably has equal or better performance to tuned java 6, but it's still early in it's life cycle and may be prone to bugs. You could give it a shot. The same command line arguments should work just fine.
  15. Offline



    This is mine, any thoughts as to why I am seeing lag spikes with only 5 users concurrently on? Any help would be appreciated.

    Server is 32GB RAM, 4x CPU VM, using Ramdisk for world.

    /usr/java/jre1.7.0_01/bin/java -server -Xmx20G -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:parallelGCThreads=4 -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=15 -XX:UseSSE=3 -XX:+UseLargePages -XX:+UseFastAccessorMethods -XX:+UseStringCache -XX:+UseCompressedOops -XX:+OptimizeStringConcat -XX:+AggressiveOpts -jar craftbukkit-0.0.1-SNAPSHOT.jar nogui
  16. Offline


    That's an ungodly large heapsize for only 5 people. Try something more reasonable like 8 gigs.
  17. Offline


    Ok ill set to -Xmx8G and let you know how it goes
  18. Offline


    Please do, and try also removing the CPU thread argument and let java decide what it needs when it needs it.
  19. Offline


    I utilize all 3 of my cores, running at 3.3GHz, I had a 2.5GHz single core server before, running at 30% with no one online, 50% or so with a single player on, now I run with 10% TOPS with all these running --
    Show Spoiler

    BlocksOnGlass .50, ChestLock 1.5.3, ChestShop 3.31, Colors 2.0, CommandBin 1.41, CommandBook 1.7, CreatureSpawn 1.6 (I dont know why I still have this), DeathRecover 1.0, Dynmap (and it's extensions, excluding residences), EasyBan, Essentials 2.8.1, EssentialsSpawn 2.8.1, Factions 1.6.2, FalconPunch .1, FalseBookIC, FalseBookBlock 0.91Alpha, HeroicDeath1.11.2, JailLikeHell 1.21, Lift6, MinecartRemover 2.1, MobRepellent 0.6, ModifyWorld 1.16, Multiverse Core 2.2AB, NoEndermen 1.5, PermissionsBukkit 1.2, Questioner 0.5, Register 1.5, SimpleHotel 1.1, Spout 721, SLAMP 1.6, TieDyeSheep 0.1.1, Towny 0.79.0, TPC 1.1, Vault 1.2.8-b87, VoxelSniper 5.100, WorldEdit 5.0, WorldGuard 5.4, iConomy 6, TeslaCoil, 2.4.3, xAuth 2.0b4.3, Buttonwarp 1.6.2, Superperms and BuyCraft.

    This is it, Right NOW. -- both players are running around doing stuff.
  20. Offline


    To be quite clear, minecraft is not multithreaded, so it uses a single thread/core/cpu/etc, but Java is multithreaded and will use as many cores as you have allowed it to use to run its garbage collection algorithms which scan its memory heap for objects that are no longer being used.

    The garbage collector can be tuned to work in different ways depending on the workload you have. In our case we want the garbage collector to interfere as little as possible with the real time processing of the main server process. In other applications where low ram usage are more important and real time responsiveness is less important, you could tune it to more aggressively scan the heap. But I digress...
  21. Offline


    Still, there is improvement, isn't there?
  22. Offline


    Yes, using the command line arguments I provide should provide improvement over using no command line arguments because it tells the garbage collector to use multithreaded methods and to not interrupt the main server process.

    It's like asking the cleaning lady to be very quiet when she comes in to clean your office while you are on a very important conference call, and to make the whole cleaning process faster by having several helpers come along with her.

    So yeah... this command line will turn the garbage collector into an army of stealthy ninja maids.
    The PC Tech Guy likes this.
  23. Offline


    Is there any way to increase the rate of garbage collection runs? Like having them run several times as often (which would decrease RAM usage and increase CPU usage)? I dug around on Google, but I didn't find any working methods.
  24. Offline


    It doesn't really work that way.

    You give java a heap of ram to use for it's program, and the garbage collector will try and keep usage within that boundary. So if you want to decrease ram usage, and increase cpu usage, just give it a smaller heap.
  25. Offline


    Smaller starting heap, or a smaller total heap?

    -Xmx does the total, -Xms does the starting, so if I set the starting heap to, say, 256M (-Xms 256M) then gc would run more often in an effort to keep the memory usage as close to 256M as possible?
  26. Offline


    Well, yes, but that isn't really a good way to go. My previous suggestion was meant to show that it isn't a good idea. By artificially making the heap small, you force java to work harder to stay within it, which is bad. It's like having too little system ram in your PC, which forces windows to page out to disk more and more to try and make use of the ram you do have.

    See my large post on page 2 for some recommended settings. You'll have to pick your ram settings by asking yourself the following questions.

    1. how much total system ram do i have? (the xmx can't be bigger than this)
    2. how much ram do other things like the os, etc need to operate? (2 gigs on a windows system is a pretty good rule)

    Therefore you want to set your xmx value to be at least 2 gigs less than your total physical ram.

    You really shouldn't specify the xms starting value either because you don't really know what's going on inside the heap from moment to moment. Best to let java mess with it. We can however give it some guidance on when to move things from the young generation heap into the old generation heap using the survivor ration and tenuring threshholds. Again, see my post on page 2.
  27. Offline


    Yeah, I'm using most of that startup line (excluding strings/large pages).

    Why is the xms starting value so bad? I played around with it and saw no noticeable difference with CPU/RAM usage. Honestly, my biggest problem is CPU, CB++ is using 15-25% of a core with a single player online, and unless I'm looking at the wrong core (could this be from garbage collection?) then this is a problem.
  28. Offline


    It's not that it's bad to use, it's just that java will now better how to adjust it on the fly than you do setting it to one single set value which may not be good for every situation. The idea is to allow java to adjust it's own settings according to the work load as much as possible.

    You could turn on garbage collection logging to see if you are getting extremely long collection pauses, but if you are using that command line and don't notice any stuttering in game, then it's probably a plugin malfunctioning or a bug in the map causing high load, like a ton of mobs spawned in one area, or a weird water flow situation. It could also be CB++, does it also happen with stock bukkit?
  29. Offline


    Yes, I played around with CB and CB++, as well as a bunch of JVM flags, and I get about 10-15% with nobody online (one core), and 20-30% with one player online (one core).

    Now, I don't know exactly what's running on said core... I have a feeling that most of the plugin activity/garbage collection is happening on that core, which would explain why it's at 30% with one user online. Is there any way that I can find out exactly what is happening thread-wise? To be clear, my interest in reducing RAM usage is just out of curiosity since I have so much of it to use, but the CPU usage is what's worrying me.
  30. Offline


    As I said, it's probably not garbage collection that is causing the usage.

    Is the game laggy or is there stuttering? If not, what's the issue? Some CPU usage is to be expected, and if performance isn't impacted, there isn't an issue.

    To try and narrow it down, remove plugins 1 by 1, if still nothing, try starting a fresh server with fresh configs.
Thread Status:
Not open for further replies.

Share This Page