by

Easy JVM CPU profiling with WarmRoast

WarmRoast is a web-based CPU sampler for the Java Virtual Machine with a few select features tailored for diagnosing Minecraft servers and clients.

  • Adjustable sampling frequency.
  • Supports loading MCP mappings for deobfuscating class and method names.
  • Web-based — perform the profiling on a remote server and view the results in your browser.
    • Collapse and expand nodes to see details.
    • Easily view CPU usage per method at a glance.
    • Hover to highlight all child methods as a group.
    • See the percentage of CPU time for each method relative to its parent methods.
    • Maintains style and function with use of “File -> Save As” (in tested browsers).

Usage

Just start WarmRoast up using your terminal/shell (or even desktop).

term

Connect to it with your web browser. If you’ve filtered all threads out but the main server thread, then you’ll see only the server thread.

wr01

Let’s expand it out to see where most of the tile entities run. (We’ll use a modded server in this example.) The numbers on the left indicate how much the selected entry takes up as a percentage of each parent routine.

Note: Only a non-modded Bukkit server, you need to look for playerJoinedWorld() and entityJoinedWorld(). That’s for entity and tile entity ticking, contrary to the names of those routines.

wr02

To understand what all this means, note that the first routine called is run(). 100% of the time in this routine was actually spent in the run() below it. However, 99.92% of the total time was actually spent in q(). If we keep going down to the highlighted line, then we can see that 17.32% of the total time was spent calling g() in the class “appeng.me.tile.TileController.” That tells us that 17.32% of the entire server’s CPU time (in the game thread) was spent on that particular function of that mod.

h() happens to be the “run all the tile entity ticking code” routine (hovering over the orange labels gives possibilities for unobfuscated names), so that basically tells us that 19.35% of the “entity ticking code” was spent on the particular function of that mod.

If we examine the results further, we see where blocks are processed (as opposed to entities and tile entities). Blocks consume less than 4% of server CPU on this server.

wr03

If we wanted to do something here, then we might consider lowering how much CPU the tile entities take (by removing mods or disabling features).

Get WarmRoast

See the README for download and usage information.

  • Jadedwolf

    Amazing.

  • Artemis2

    Very good work! I hope it will help some beginners admins to understand from where lag comes.

    sk89q, amazing (as usual).

    • http://www.sk89q.com sk89q

      Ha, I am using locale-specific number formatting for the percentage point numbers, so it prints XX,YY% rather than XX.YY% (comma versus full stop) for half of the world, but web browsers only accept full stops as the decimal mark.

  • Dave

    Having some trouble getting started. If anyone has any insight into Error: Could not find or load main class java.library.path=.usr.bin I’d appreciate it. Running in CentOS. Have java 7 and jdk installed.

    • Verttex

      Your %PATH% isn’t set up correctly.

  • Martin Frühauf

    It says the following, after I ran that command: ‘java -Djava.library.path=/usr/lib64/jvm/jre1.7.0_21/jre/bin -cp /usr/lib64/jvm/jre1.7.0_21/lib/tools.jar:warmroast.jar com.sk89q.warmroast.WarmRoast –thread “Server thread”‘:

    Fehler: Hauptklasse com.sk89q.warmroast.WarmRoast konnte nicht gefunden oder geladen werden
    (Error: Main class com.sk89q.warmroast.WarmRoast could not be found or loaded)

    What did I do wrong?

    • http://www.sk89q.com sk89q

      Does warmroast.jar exist?

      That error means that it looked in the files:

      * /usr/lib64/jvm/jre1.7.0_21/lib/tools.jar
      * warmroast.jar

      For the class com.sk89q.warmroast.WarmRoast, but it didn’t find it. Java won’t complain if one of those files doesn’t exist.

      • Martin Frühauf

        Yes, (now) it exists, but there is a new error:
        http://pastebin.com/5k9AzGMy
        I believe the tools.jar does not exist in the folder “/usr/lib64/jvm/jre1.7.0_21/lib/” (I didn’t found it)…

        • http://www.sk89q.com sk89q

          You need to be using the JDK and not the JRE.

  • jakimfett

    When I start up warmroast and attempt to select my server, I get this error:

    com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded
    at sun.tools.attach.LinuxVirtualMachine.(LinuxVirtualMachine.java:102)
    at sun.tools.attach.LinuxAttachProvider.attachVirtualMachine(LinuxAttachProvider.java:78)
    at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:255)
    at com.sk89q.warmroast.WarmRoast.main(WarmRoast.java:282)

    • http://www.sk89q.com sk89q

      Are you using it under the same user as the server process?

      • jakimfett

        In theory, yes. I’m running Multicraft, so everything is running under the “root” account. Also, the root account is the only user account that shows any java processes other than the warmroast process.

        • Tatara88

          multicraft starts its processes under the multicraft user account.

          • jakimfett

            Actually…multicraft runs under the user that you specify in the config. The multicraft daemon runs as the root user, and then you can specify either a single user to run the servers as (by default, username ‘multicraft), or each server as its own user. My config is set to run each server under its own user, but when i run warmroast under that user, nothing shows up except the warmroast process. The root user shows all the running servers, but when I select one of them, the error I pasted above happens.

  • Karl

    Works perfectly, but one issue though, when I try to select another VM.
    The default VM: [1] com.sk89q.warmroast.WarmRoast –thread Server thread

    works just fine.

    But the craftbukkit VM doesn’t work;
    http://pastebin.com/y193F2Lq

    • http://www.sk89q.com sk89q

      Are you running the server under a JRE?

      And WarmRoast under a JDK?

      And who maintains the JRE? Is it OpenJDK? What about the JDK? Oracle?

      • Karl

        Right, let’s see,

        The server is running under JRE; java-1.7.0-openjdk-1.7.0.25-2.3.10.4.el6_4.x86_64
        WarmRoast is running under The Oracle JDK. jdk1.7.0_25

        That’s it, I think.

        • http://www.sk89q.com sk89q

          Since you have the JDK now, you might as well just run the server under the JDK too.

          • Karl

            Awesome, thanks!

            Everything works now.

            Just a question. Is it supposed to show something on the main page, or are you required to click View sampler results button thingy?

  • Fl_Dutchman

    I get this Error:

    Exception in thread “main” java.lang.UnsatisfiedLinkError: no attach in java.library.path

    at java.lang.ClassLoader.loadLibrary(Unknown Source)

    at java.lang.Runtime.loadLibrary0(Unknown Source)

    at java.lang.System.loadLibrary(Unknown Source)

    at sun.tools.attach.LinuxVirtualMachine.(LinuxVirtualMachine.java:336)

    at sun.tools.attach.LinuxAttachProvider.attachVirtualMachine(LinuxAttachProvider.java:78)

    at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:255)

    at com.sk89q.warmroast.WarmRoast.main(WarmRoast.java:282)

    I do use the same user for this programm and for the minecraft server.

    • DerFlash

      Same here. Started from within /home/games/bin/ with:
      java -Djava.library.path=/home/games/minecraft/servers/main -cp /home/games/bin/jdk1.7.0_40/lib/tools.jar:/home/games/bin/warmroast.jar com.sk89q.warmroast.WarmRoast –thread “Server thread”

  • fabio sepulveda

    como mierda se descarga

  • Daniel Gaardbo Christensen

    I get this error :(

    Failed to attach VM
    java.io.IOException: well-known file is not secure
    at sun.tools.attach.LinuxVirtualMachine.checkPermissions(Native Method)
    at sun.tools.attach.LinuxVirtualMachine.(LinuxVirtualMachine.java: 117)
    at sun.tools.attach.LinuxAttachProvider.attachVirtualMachine(LinuxAttach Provider.java:78)
    at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:255)
    at com.sk89q.warmroast.WarmRoast.main(WarmRoast.java:282)

  • Trollface

    hey SK, your plugins work very well for my server! Finally i can remove p***s pixelarts from my creative server :D

  • an

    Would love to compare previous results with current results.

    • an

      Or even as far as automagically showing anomalous changes.

  • fredghostkyle

    win. 8 got to love it :P

  • Slind14

    How does this work with opne jdk ? There is no tools.jar

    • http://www.sk89q.com sk89q

      Unfortunately, I don’t think it does.

  • pyrex

    I got it installed and running. When I go to the website, it loads but no threads are displayed.

    • http://www.sk89q.com sk89q

      Try removing –thread “Server thread”

  • Philip Lawall

    I installed it and it is running but the WebInterface doesn’t show any Data http://pastebin.com/Crz5EdBq http://puu.sh/6CKkK.png

    • http://www.sk89q.com sk89q

      Make sure to click “View sampler results”

    • user921

      gives this error

      Exception in thread “main” java.lang.NoClassDefFoundError: com/sun/tools/attach/
      AttachNotSupportedException
      at java.lang.Class.getDeclaredMethods0(Native Method)
      at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
      at java.lang.Class.getMethod0(Unknown Source)
      at java.lang.Class.getMethod(Unknown Source)
      at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
      at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
      Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.AttachNotSuppo
      rtedException
      at java.net.URLClassLoader$1.run(Unknown Source)
      at java.net.URLClassLoader$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      … 6 more

      • http://www.sk89q.com sk89q

        Check the path that you have to PATH_TO_JDK/jre/bin and make sure that it has an attach.dll in it (or .so on Linux probably).

  • TANJX

    why i can’t open it

    • TANJX

      how to start WarmRoast up?
      i can’t understand the description.
      please make a video.thanks

  • hook

    I cant use the Oracle JDK, is it possible to get this to run on openjdk?

    • hook

      PS. tools.jar does exist when openjdk-6-jdk is installed.
      /usr/lib/jvm/java-6-openjdk-amd64/lib/tools.jar

      But I get the error:

      Exception in thread “main” java.lang.UnsupportedClassVersionError: com/sk89q/warmroast/WarmRoast : Unsupported major.minor version 51.0

  • therealduckie

    Runs, but errors our on starting webserver.

    Any clues in this? http://pastebin.com/Rv0MXsg0

    Posted image of error plus pastebin of same.

    Running BungeeCord on Debian Linux with JDK1.7.0

    Using this command: /opt/jvm/jdk1.7.0/bin/java -Djava.library.path=/opt/jvm/jdk1.7.0/jre/bin -cp /opt/jvm/jdk1.7.0/lib/tools.jar:warmroast-1.0.0-SNAPSHOT.jar com.sk89q.warmroast.WarmRoast –thread “Server thread”

    Thanks for any help you can offer.

    • http://www.sk89q.com sk89q

      That error would be thrown if you weren’t using Java 7. Maybe try using a newer version of Java 7?

  • Danny

    Not sure what this means. Unless Warmroast doesn’t like openjdk.

    java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
    java.io.EOFException
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:228)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:161)
    at javax.management.remote.rmi.RMIServerImpl_Stub.newClient(Unknown Source)
    at javax.management.remote.rmi.RMIConnector.getConnection(RMIConnector.java:2392)
    at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:308)
    at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:268)
    at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:227)
    at com.sk89q.warmroast.WarmRoast.connect(WarmRoast.java:129)
    at com.sk89q.warmroast.WarmRoast.main(WarmRoast.java:327)
    Caused by: java.io.EOFException
    at java.io.DataInputStream.readByte(DataInputStream.java:267)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:214)

    • Danny

      Decided to stop all my servers, uninstall openjdk and install oracle jdk on all of them. Warmroast works perfectly fine.

  • Rob

    I would really love to give this a try but this is what I get when I run it with a .bat.

    A:MinecraftServerwarmroast>java -Djava.library.path=C:Program Files (x86)Ja
    vajdk1.7.0_71jrebin -cp C:Program Files (x86)Javajdk1.7.0_71libtools.jar
    ;warmroast-1.0.0-SNAPSHOT.jar com.sk89q.warmroast.WarmRoast –thread “Server thr
    ead”

    Error: Could not find or load main class Files

    A:MinecraftServerwarmroast>pause

    Press any key to continue . . .

    • http://www.sk89q.com sk89q

      You need to put quotation marks around the staff after -cp but before com.sk89q

      • Rob

        Ok so I’ve tried placing the quotation marks like you suggested, I ended up with the same result. I’ve also read through as many comments on this as I could find, as a result I’ve uninstalled all of my java programs. I reinstalled the 64bit Version 7 Oracle JDK (I downloaded the 32bit the first time) and set up my server to run off the JDK enviroment. I updated my paths to run the 64bit version but now when I run the .bat this is what my console tells me:

        C:UsersScotDesktopwarmroast>java -Djava.library.path=C:Program FilesJavajdk1.7.0_71jrebin -cp “C:ProgramFilesJavajdk1.7.0_71libtools.jar;warmroast-1.0.0-SNAPSHOT.jar” com.sk89q.warmroast.WarmRoast –thread “Server thread”

        Error: Could not find or load main class FilesJavajdk1.7.0_71jrebin

        C:UsersScotDesktopwarmroast>pause

        Press any key to continue . . .

        I’m gunna keep tinkering, hopefully I’ll figure it out! :)

        • Rob

          Just to make sure, you need to have the warmroast.jar in the same folder as the .bat correct?

        • Rob

          Hey got it working!!!!! Just some formatting issues. If anyone has the same issue I’m running Windows 7 Ultimate 64bit with JDK7 64bit, this is the .bat I used:
          ——————-

          java -Djava.library.path=”C:Program FilesJavajdk1.7.0_71jrebin” -cp “C:Program FilesJavajdk1.7.0_71libtools.jar;warmroast-1.0.0-SNAPSHOT.jar” com.sk89q.warmroast.WarmRoast –thread “Server thread”

          pause

          ——————–

          Your file path will obviously be different but at least this might give you an idea of the format.

          Thanks sk89q!!!! I’m going to love using this, no more trial and error lag trouble shooting! :D