Skip to main content

JavaOne 2008 - some brand new monitoring and profiling tools for your Java apps

Posted by johnsmart on May 7, 2008 at 9:24 PM PDT

Performance monitoring and profiling applications is one of my favorite pet topics - indeed, there's a big chapter on tools in this area in Java Power Tools. So I was keen to here what Jaroslav Bachirik and Gregg Sporar had to say in their talk today, entitled "Improving Application Performance with Monitoring and Profiling Tools".

It was worth it. Naturally, they talked about the JDK tools such as jps, jinfo, jhat, and JConsole, and the Solaris-specific tool DTrace. JHat got a special mention as being the only tool to date capable of diagnosing permheap issues.

The NetBeans profiling tools, which are very good, were also discussed. NetBeans has powerful and smoothly integrated profiling features built right in to the IDE, which makes it very pleasant tool to use for profiling and performance tuning.

But there's more. They also discussed BTrace, a new tool for dynamically tracing a running Java application. It uses a fairly AOP-style approach where you write a script to indicate which classes and methods you are interested in monitoring. The script is actually a simple annotated Java class. For example, in the following code (shamelessly stolen from the BTrace documentation ;-) ), you set up a call-back method (func()) that will be called whenever the Thread.start() method is called:

public class HelloWorld {

    // @OnMethod annotation tells where to probe.
    // In this example, we are interested in entry
    // into the Thread.start() method.
    public static void func() {
        // println is defined in BTraceUtils
        // you can only call the static methods of BTraceUtils
        println("about to start a thread!");

Then you simply run BTrace against your running Java process. Easy!

The other new and interesting tool they mentioned is VisualVM, a very cool new profiling tool being developped at Sun. Visual VM (just out as an RC) gives you a high level, graphical overview of profiling data and statistics, and letting you drill down for more details about memory consumption or thread use, or to display graphs indicating the methods that your application is spending the most time executing. You can't drill down to the line level the way you can in the NetBeans profiler, but, still, it's a pretty neat tool.

Related Topics >>