Optimize JAVA for MineCraft in a EXTREME way :P -- NEED FEEDBACK, THX !! [- I AM BACK -!]

Discussion in 'Bukkit Discussion' started by Therawroy, Jul 13, 2011.

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


    Monstertke: lol, i really understand you and some others ... but! there is some difference if you change some stuff ... but its not that big in CPU or RAM advantage, but i search for a good balance between them.

    So in the end 10-20% more speed or less ram is really not that important ... but is it really sooo bad that i try to help other people ? I mean there is no one here who had an problem or lost his world or whatever .... its for the small servers on this world, so that they can also play minecraft .....

    PS: Got my new Server Ready :p

    Core i7 950 // 8GB RAM // 1500GB HDD RAID0 and i try Ubuntu 11.10 with Kernel 3.0 RC5 :p
  2. Offline


    PSS: I also measure the difference between the Java Command Lines with built in tools and some extern Tools, so i can give you in the end a much shorter command line ;)

    And i see you got some technical skill in this things....but java and the use of the commando lines (and the monitoring) showed me which commandos worked .... and i mean look at the RAM and Performance ... what is there else to say ?
    I got also my technical skill, and this would not be the first time that i had an better answer to a question then most people who are involved with it. And besides .... its only for help, but i am bored after reading that.

    Copy, Google and understand the command is one thing ... monitoring and testing and searching for the reason is another.

    Enough of the harsh words :p Its monday .... thats all
  3. Offline

    will d

    If you care more about CPU usage than memory usage, you should not be using NewRatio=3 or -Xmn256M at such a low value (in fact, you'd be better off not setting this argument at all). Both of these changed settings (as opposed to leaving them omitted or default), cause more CPU usage.
  4. Offline


    Thanks. I mean to me I don't give a shit about memory all about cpu haha.
  5. Offline


    Want a little bit more horsepower [EXPERIMENTAL] .... then put -Xrs in your command line ;)

    Also....search with the command "top" for the PID of "java" and use the command:

    renice 18 "PID NR" example: renice 18 3765

    The command gives "java" a much higher priority

    PLS PLS PLS dont set it higher ... even 19 can crash the total system !!!!
  6. Offline

    will d

    I'm actually kind of baffled at this post here. I don't mean to sound mean, but this particular post is only illustrating you're not properly comprehending the java arguments you're talking about.

    As you say, "Copy, Google and understand the command is one thing ... monitoring and testing and searching for the reason is another."

    So the question I raise is this: did you test your server without -Xrs and then WITH -Xrs and then found you got a 'little bit more horsepower'?

    If so, I am astounded, since the function of -Xrs has no performance ramifications: "Note that -Xrs (reduce signal usage) is a JVM option that can be used to prevent the JVM from using most signals. "
    (reference: https://www.ibm.com/developerworks/ibm/library/i-signalhandling/)
    In other words, this argument makes numerous events, such as "Bus error (attempt to address nonexistent memory location)" or "File size limit exceeded" or ....... "Termination request. JVM will exit normally." basically do nothing. These are functions...interior functions you do not want to disable and provide no performance impact. To think that by ignoring requests for a JVM to close normally you are squeezing out extra CPU power is ... downright folly. And if you are saving CPU power, is it...what, one dozen out of the 3 million you get per second?

    This is just downright terrible advice; it's hard to be diplomatic about it. And that doesn't even tackle the other glaring issue of renicing java.... You know that the renice scale goes from negative to positive, right...where -20 means "high priority" and +20 means "lowest possible priority?" So you're recommending to all these users to put java priority lower than every other possible service on the machine. How is that maximizing performance?
    fysics likes this.
  7. Offline


    20 = low priority
    -20 = high priority

    its easy
  8. Offline


    nothing :p its late here

    So i can ALSO make a mistake =( .... PLS forgive me .... but its nice that you all have so much effort in this case =)

    He is right ... change it to (-)

    And Xrs- is helping a little bit if you are using a Virtual Machine .... its not over 5-8% .... but you know , i like it long .... like my command lines xD

    Sorry .... :p Its late here
  9. Offline


    This thread is a day late and a dollar short anyway. This has been mostly thrashed to death on other threads. And its obvious at this point that will d knows FAR more about this subject than you do. All you have to do is read the whitepaper with a little comprehension and you will get farther than what you are suggesting.

  10. Offline


    Ladys, i got my new server ... no vServer and Power like a Beast ... and enough RAM :p

    And to get some heat away from the thread, i can understand now why people with Big Servers dont see that much difference ... you can notice some things and also measure it, but its a huge difference from my vServer.

    In the end ... if you got the Power and Ram, you probably dont need all the stuff in the command line ..... but if you have a real poor server and low memory ..... my command line is the way to go =)
    [Until you buy a new Server]

    Thx for all your Feedback ... even if you tried to be mean to me :p And Sorry for my english ... i am german ;)

    And for now, my last command line .... specially optimized for ya and almost BETA Status :p Thx to VMWare and the abilities it gave me to test the stuff directly.

    -- And if you dont know what comes now .... here again ..... BACKUP YOUR WORLD !!!

    1. - Orange commands can be changed or removed (if needed)
    2. - Pink commands can make Problems (try or die :p)

    [64 Bit Optimized for pure Satisfaction]

    java -native -server -Xincgc -Xmx6144M -Xms2048M -Xmn512M -XX:NewRatio=3 -Xrs -XX:+UseThreadPriorities -XX:CMSFullGCsBeforeCompaction=1 -XX:SoftRefLRUPolicyMSPerMB=2048 -XX:+CMSParallelRemarkEnabled -XX:+UseParNewGC -XX:+UseAdaptiveSizePolicy -XX:+DisableExplicitGC -Xnoclassgc -oss4M -ss4M -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseConcMarkSweepGC -XX:UseSSE=4 -XX:+UseCMSCompactAtFullCollection -XX:ParallelGCThreads=4 -Xcheck:jni -Xfuture -XX:+AggressiveOpts -cp "craftbukkit-0.0.1-SNAPSHOT.jar" -jar "craftbukkit-0.0.1-SNAPSHOT.jar" nogui

    [32 Bit Optimized for longtime Crafting !!!]

    java -native -server -Xincgc -Xmx2048M -Xms512M -Xmn256M -XX:NewRatio=2 -Xrs -XX:+UseThreadPriorities -XX:CMSFullGCsBeforeCompaction=1 -XX:SoftRefLRUPolicyMSPerMB=1024 -XX:+CMSParallelRemarkEnabled -XX:+UseParNewGC -XX:+UseAdaptiveSizePolicy -XX:+DisableExplicitGC -Xnoclassgc -oss4M -ss4M -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=90 -XX:+UseConcMarkSweepGC -XX:UseSSE=4 -XX:+UseCMSCompactAtFullCollection -XX:ParallelGCThreads=2 -Xcheck:jni -Xfuture -XX:+AggressiveOpts -cp "craftbukkit-0.0.1-SNAPSHOT.jar" -jar "craftbukkit-0.0.1-SNAPSHOT.jar" nogui

    - And did you see ??? I got a fix for the smiley problem :p
    -->> With this Settings, i tried to gain something like 5-10% better Java Utilisation for 32 / 64 Bit Systems ..... Have fun =)​

    -- And if you dont know what comes now .... here again ..... BACKUP YOUR WORLD !!!
  11. Offline


    I like the Internet ... you can see all dates ;) And this was today .... nice try ... next one ;) .... nah read my text above and cool down :p

    And for the Rest ... try my new command line above and have fun :p

    By: a guest | Jul 20th, 2011 | Syntax: None | Size: 0.48 KB | Views: 11 | Expires: Never
  12. Offline


    Lol the above paste is copied out of my McMyAdmin .conf about 20 seconds before I replied to your post. So yea Im busted. ;)


    This ^^^^ is what I was talking about when I said that this was a rehash. But whatever, Java is forgiving it will either create the VM or it wont. Also throw 75 people on then run your benchmark, Cause dynmap fullrender isnt very taxing and I doubt that any of its chunkloads arent picked up By Gc in the young generation when it is most efficient.

    With Bukkit #1000 I can go 36 hours with an average of 40 people (high 60 low 10) on, before hitting the FullGC thrash of death. Core i7 860, 16Gb DDR3 with 12 set to largepages and dedicated to java.

    Ps. Xcheck:jni is pointless, its a debugging tool and ads overhead.
  13. Offline


    Hi, can you tell us how to distribute the server on every core?
  14. Offline


    No, he could give you a vague guess on how to wrongly do it though.
  15. Offline


    Some people asked me if i just test it with trial and error (or google), or if i have a real idea of what i am doing ....

    So here is a little screenie from one of the tools i use .... you can clearly see all the things which has been discussed here lately in a nice gui. And i can play with the garbage collectors .... to test and ensure you have a nice playing time ;)

    Its only a small part of the whole programm ... but i need to protect it for the haters ;)

  16. Offline


    Good. Tell me your arguments above, only work on Java 7? How many players are online?
  17. Offline


    And if you wanna optimize it a little! for Multi Core .... try:

    apt-get update
    apt-get install irqbalance [nice one ... gives every free cpu something to do]
    apt-get install preload [The Name is programm ;) a must have]
    apt-get update
    apt-get upgrade
  18. Offline


    Sorry pomo4ka, i didnt see your text.

    I tried almost 98% with Java 7, because i am a fan of new stuff .... and Java is since the beginning crappy ... yeah it works on almost every device ... but slow and shitty. So after i heard there are some usable Snapshots, i was the first who tried. There was a little speedplus ..... but nothing real. And i learned at this time that my server is too weak for my project. So what to do ?? Change the Server or optimize the Crap out of it (my favorite way) if its realistic ... and you read my results :p

    So i choose of knowledge, experience and some luck the commands for the Problems i monitor .... not all commands are from Java 7 .... there are also some real old ones in there :p
    But what makes the difference ??? I can really measure it and give it first hand from a poor vServer / VMWare on good PC / Hardcore Dedicated Server ...... and maybe Android soon xD

    Love me or hate me .... but i am away .... searching for food ;) cu later
    pomo4ka likes this.
  19. Offline

    will d

    Based on the heap size in his GC screenshots, I'd say there's ... one player on? Maybe a second client? Zero cpu, so they're definitely just sitting around.

    To address all your 'to you haters' lines, I don't have a problem with you coming up with anecdotal answers to problems, but you do not seem to be generalizing them or properly using them as evidence for any real-world application.

    As an example--from a 'theoretical' viewpoint, I don't see that you should value -- AT ALL -- free memory in relation to your maximum heap size. We all know that with java, there is the maximum heap size, and the accompanying java/stack overhead that comes with it. So a heapsize of 2048 in a running java instance we should expect to take > 2048 by a slim margin (something like 50MB). But looking at 'top' and seeing that instead of your server rocking out a 2048+ working set, you're finding victories in seeing 600MB(!!!).

    The way to look at it (as I see it) is like this: under maximum capacity of your server, you are permitting minecraft to use 2048 MB. If the heap size is currently at 600MB and you have 1400 free megabytes...that memory is doing nothing for you, at all. If Java has to slowly claim more and more memory until it hits the 'real-world' goal of high-pop server and reaches 2048, what was saved by having the heap size reduced to start?

    In other words, if you're basing successful java tweaks on the working set (memory footprint), so you can MINIMIZE it....then run OTHER STUFF in the background---that does not seem like maximizing your minecraft server at all--it feels like maximizing the multi-tasking ability of your server, which is a completely different goal.

    You're essentially finding how to do other things on your server, which other admins may or may not need/want to do. That goes back to my 'one-size-does-not-fit-all' issue, wherein your solution (java tweaks) may tackle a problem you're having, but you're claiming it fixes a problem for anybody who has unoptimized minecraft performance issues and 'wants more horsepower'.

    That's the point of so many other admins in the world, like myself, of making the minimum and maximum heap size the same; we are tailoring our servers to operate its other tasks, like dynmap, both when the maximum heap size is reached (minecraft load capacity reached), and when not at capacity--not 'dynmap' works great when theres a lull in the minecraft world and java can re-release memory to the system.

    if tldr: you're claiming to have struck oil when you really just found a spill on your driveway. Your tests are not rigorous enough to make these un-intuitive, counter-productive tweaks proof of improvement.
    mooman219 and Lunar Delta like this.
  20. Offline


    what could be changed on this config to reduce CPU usage ?
  21. Offline


    I don't think you understand, man. These launch options will make your MineOS 2x longer.
  22. Offline

    EvilSeph Retired Staff

    All of these threads detailing how to optimise the JVM are misleading and inaccurate. Generally, the JVM is pretty good at optimising itself based on the environment the JVM is running in (with a few obvious exceptions). Any other optimisations require a lot of time and trial and error to figure out what configuration is right for your server. Every java application is different, and on top of this, every server environment is different too.

    By just throwing random flags into the launch line you run the risk of undoing the automatic, and correct, optimisations the JVM has chosen to use based on the system environment it is running in. While some of these flags can improve performance, most of this is just the placebo effect in play. Your post provides a list of flags with no explanation as to what each one does and what effect they have on the JVM and this is polarly contrary to how system optimisation should take place. Just like overclocking a PC, you need to do things in baby steps and spend countless hours rigorously testing each change for at least a week in order to really figure out what is beneficial to the performance of the JVM in relation to the program and what isn't.

    Usually, you can very quickly find the answer to a question by using Google. Has it not, then, struck anyone as odd that there is no proper guide written to tune your JVM? It's because one can't be written; it's not that easy.

    Nonetheless, here are some observations I've made based on what I've seen people trying:
    -server - this switches the compiler to an optimizing one that generally results in a significant increase in performance, at the expense of a longer warm up time.
    -d64 - this makes the JVM run in 64bit mode. However, if it isn't already doing so, you can't force it as such, so this flag is useless.
    -Xnoclassgc - this flag should not be used with CraftBukkit as we make EXTENSIVE use of reflection and could lead to a large memory leak as a result of all the dynamic classes not being garbage collected when they need to be, since you are telling it not to…
    -XX:+AggressiveOpts - this flag is a quick way to turn on multiple optimisations but I have not looked into if this would increase or decrease performance for CraftBukkit.

    Garbage Collector selection:
    Parallel Collector: -XX:+UseParallelGC
    Concurrent Low Pause Collector: -XX:+UseConcMarkSweepGC
    Incremental Low Pause Collector: -Xincgc

    Since you're selecting *a* garbage collector, it makes sense that you can only choose one. Having multiple flags choosing different GCs in the same launch line will just have the JVM pick the last one you specified. The only exception to this is if you want to run a Concurrent Low Pause Collector with a Parallel YOUNG Generation Collector:
    -XX:+UseConcMarkSweepGC -XX:+UseParNewGC

    Once you've chosen your garbage collector, if you even want to, you should then leave it up to the JVM to decide what parameters the GC should follow. For example, a lot of people tell you to specify how many threads a parallel GC should have, but you run the risk of specifying the wrong amount - the JVM knows best and has already set it as such.

    Anything that uses System.gc() to try and explicitly force a garbage collection (even though it won't) is detrimental to the performance of your system. If there's one flag I'd recommend everyone use, it is -XX:+DisableExplicitGC to prevent naughty software from trying to do this. Leave it up to the JVM, it knows best. Some plugins like Essentials and, I believe, Performance Tweaks do this and it is strongly recommended against. While it merely provides a hint to the JVM, there is still a chance that it could cause a GC to occur when it shouldn't and is not needed.

    In relation to the advice given in this specific thread, you have suggested people use conflicting flags like enabling the incremental garbage collector, then later enabling the concurrent one, followed by enabling the parallel one. Which one should the JVM use now!? It really seems like you scoured Google for JVM flags and just threw them into one launch line without any knowledge as to what effect they would have on the JVM.

    In conclusion: unless you understand how the JVM works and how the application you're trying to tune handles memory, you're better off just sticking with letting the JVM do what it does best, handling the optimisations. I've probably forgotten to address some issues, but I think this will help out some people for the time being.
  23. Offline


    and /thread

  24. Offline

    Lunar Delta

    This. I think I told him at the beginning of the thread that Xincgc and ConcMark didn't go together, but he didn't listen... D:
  25. Offline


    i never said anything against it :p I just wanted to check it myself ... and arent we all humans in the end ?? So mistake is what us defines :p
  26. Offline


    I would like to try this but have no idea how to install JDK 1.7 onto CentOS.

    I have downkloaded the tar.gz file but cannot find a guide on how to install. Can someone assist me?
  27. Offline


    It wasnt hard, as soon as I get a free 10 minutes Ill look at my notes and edit this post.
    Centos has its peculiarities.
    Deanouk87 likes this.
  28. Offline


    Cool, thanks! It's my first proper experience with linux, nice learning curve so far.
  29. Offline


    Lol, sorry man I lied. I have a management package with singlehop. I had them do it.
  30. Offline


    Nevermind then... I'll try and work it out.
Thread Status:
Not open for further replies.

Share This Page