Saturday, January 06, 2007

Profiling tools for Java

When your web application developed some months ago, does not perform well or cannot support the number of users hammering at it, profiling is the way to go. Performance tuning is a difficult job and trying to solve it by looking at source code is like trying to throw sticks at a huge beast. So you choose the place to attack very carefully and thats what the profiling tools are designed for.

Till sometime back, the commercial ones like JProbe, OptimizeIt and JProfiler were the only tools of choice, and the open source tools were limited to taking snapshots of Java heap and then looking at the numbers. But now you can save a lot by utilizing open source tools, and some of them even offer features not available in commercial tools. Recently I happened to review the various tools available for profiling a Java web application, and I started out with this big list. I have always liked the complete lists of open sources available at manageability, but the absence of any comparisons makes it difficult to use.

First I shortened the list by cutting down the tools which did not have the following essential features -
  • Easy to install and configure
  • No modification to existing code
  • Profile server side applications
  • Decent documentation
  • Visual representation of statistics
  • Active development
  • Dynamic statistics, and not snapshots
You might be able to work with some of the following missing, but I really wanted a tool which wouldn't make our developers throw their hands in frustration :) So this limited the choice to a handful which were reviewed.

ToolFeaturesLimitations
Glassbox
  • No configuration required
  • Shows possible problem in the code, not statistics
  • Understands web frameworks like Struts
  • Does not show possible memory leaks
Jmemprof
  • Shows detailed memory statistics by class and method
  • Runs very slowly with Sun JDK
  • No visualizations
  • GUI only shows statistics not clickable call graphs
  • No CPU statistics
GCSpy
  • Shows various generations of objects
  • Requires conceptual understanding of GC
  • Does not show statistics or visualization at source code level
Eclipse Profiler
  • No configuration required
  • Shows graphs of memory
  • CPU statistics available to a good detail
  • Memory profiling limited to showing heap memory usage
InfraRED
  • Shows bottlenecks in the code
  • Analyzes the application as layers and allows drill down to expensive pieces like views and queries
  • No visualizations
  • Does not profile memory
EJP
  • Simple to use
  • Ability to drill down within functions with timing
  • No support for memory profiling
  • No visualizations
  • Limited number of users
  • Does not seem to be under active development
Netbeans Profiler
  • Very nice visualizations
  • Profiling of memory as well as CPU
  • Step by step documentation with screenshots
  • Works with NetBeans IDE only
Eclipse TPT Platform
  • Profiling of memory as well as CPU
  • Supports many servers
  • Good documentation
  • Better visualizations are needed
jvmstat
  • Shows sizes of various generations of objects
  • Monitors garbage collection activity
  • Requires understanding of garbage collector
  • Runs on J2SE 5.0 only
  • Not for detailed profiling at classes/method level


The recommended tools for profiling are Eclipse TPT (Testing and Performance Tuning) Platform and Netbeans Profiler. Both these tools come close to commercial tools by providing features like memory and CPU profiling both, professional interfaces for drilling down to the problems, visualizations and helpful tutorials. jvmstat is the recommended tool for performance tuning of the JVM.

Glassbox and InfraRED are great tools during application development since they pinpoint possible issues without any code on part of the developer and can point performance problems before the code reaches the QA.

0 Comments:

Post a Comment

<< Home