Imagine a bacon-wrapped Ferrari. Still not better than our free technical reports.
See all our reports

10 Reasons Why Java Rocks More Than Ever: Part 8 – Profiling Tools

OneDoesNotSimply

We all know that writing code is the easiest part of application development. Tracking down problems, and especially those related to performance and concurrency, is what’s tricky. While I was always aware that the Java Virtual Machine provided great forensics tools, it was only when I worked with Python and C++ for three years that I was confronted with the sad reality outside of Java land. That reality is best summarized as: “You’re on your own dude, good luck!”

Since there’s really not much to compare the Java profiling tools to, in this blog post I’ll summarize a few observations about performance testing and why Java makes this as easy as it can get.

As a reminder, here are my top 10 favorite things about the Java platform again:

  1. The Java Compiler
  2. The Core API
  3. Open-Source
  4. The Java Memory Model
  5. High-Performance JVM
  6. Bytecode
  7. Intelligent IDEs
  8. Profiling Tools
  9. Backwards Compatibility
  10. Maturity With Innovation

Measure … before you jump

The worst thing you can do when trying to fix a performance problem is to make assumptions. You’re guaranteed to either make things worse or to waste precious time while your application is sliding into the pits of doom. It’s tempting to head for the code and to barge in with the fix that intuitively rears its head, but that’s where it’s best to show restraint and to measure … measure and measure again. Without finding the root cause, you’re shooting blanks.

The question is how do you measure? Well, with the Java platform this is easy! You already have capable profiling tools in the JDK itself. If you haven’t tried it yet, make sure to give VisualVM a go. If you need to go further than that, there’s a plethora of free or affordable tools available that take the measurement and analysis to the next level.

Here are some of my favourites: YourKit, Plumbr, and Java Mission Control.

Measure … meaningful data

The Java Virtual Machine has been created with profiling and monitoring in mind. This is especially important since you have to do absolutely nothing to your code to get useful data out of profilers. Even more amazing is that you can just as easily profile remote applications as local ones. You can even profile running production code without having to take the server down and without imposing any measurable performance impact!

When I started using YourKit for this many years ago, it took me months to get over how cool this is. You’re actually analyzing your application in exactly the situation that is showing the symptoms. You don’t have to artificially build test scenarios to try to reproduce performance problems that were discovered in production. You also don’t have to work with an artificially small sample set to avoid impacting your live applications. YourKit and Java Flight Recorder can record hours of application use and you can analyse it comfortably after the fact.

Measure … more effectively

Performance tuning is one of the most overlooked skill for developers and my friend Kirk Pepperdine has dedicated much of his career to specialize in this area. During his workshops he finds that testers have an easier time finding the root cause than programmers, since instead of reaching straight for the code, they measure, observe and analyze the data.

So pull your head out of the code and embrace the monitoring and profiling capabilities of the JVM, it often beats any other solution to quickly pinpoint the cause of a problem. If you want to learn more, you can find all Java performance tuning information on http://www.javaperformancetuning.com.


Author’s note: Hey, thanks for reading :-) Up next in my series is Part 9 – Backwards Compatibility. In the meantime, check out more blogs by me, leave your comments below and you can get a hold of me via Twitter at @gbevin or @RebelLabs.

Read more awesome content from Geert
 

  • Juan David Pastás Rivera

    casual question:

    “The Java Virtual Machine has been created with profiling and monitoring in mind”

    do you meant there is a difference with profiling and monitoring? have you written about that?