Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looking for recommendations for end-to-end Java CPU Profilers [closed]

Tags:

java

profiling

What are some good end to end CPU profilers that exist for Java?

Quick list of things I'm looking for:

  1. Offline profiling - No user interaction or GUI required during program execution. Dumping the profile data to a file and then requiring viewing afterwards with a GUI is fine, I just don't want to have to babysit it as the job runs
  2. End to End recording - Profiler should be able to start recording immediately after entering the main call for a J2SE application. It should stop recording immediately before the JVM exits.
  3. Call graph generation - After profiling, it'd be nice to turn the data into a visual call graph.

Google has a nice profiler for C/C++ - http://google-perftools.googlecode.com/svn/trunk/doc/cpuprofile.html

If the Java equivalent of this exists, it'd be exactly what I'm looking for.

I'm not including HProf in my list of prospective profilers because it performs badly compared to other commercial profilers I've looked at when you use accurate CPU call profiling (Usually done via Byte Code Injection, which is slow, but HProf appears at least an order of magnitude slower than other profilers, and when a single sampling profile run takes 1-2 hours, waiting more than a day for the same run is unacceptable)

like image 294
Tulenian Avatar asked Dec 24 '08 20:12

Tulenian


2 Answers

My favorite, by far, is JProfiler. I didn't realize it until just now (because I always use the interactive profiling GUI), but it does in fact support offline profiling, exactly like you described.

A few other cool features:

  • It profiles all your SQL statements, so you can see which DB queries are slowing you down.

  • It keeps track of which methods (in which classes & packages) are allocating the most memory, for which types of objects & arrays, and the longevity of those objects. So, if you're leaking memory, it's easy to track down which types of class instances are outliving their usefullness, and to find the methods where those objects were originally allocated (and who's holding the references that are keeping the objects alive).

  • You can keep track of the VM growth, monitoring the frequency of GC full collections, and determining how many objects (of which type) were freed during each collection cycle.

  • And of course, you get a hierarchical breakdown of all method invocations, with the number of calls and mean execution time (exclusive or inclusive) of the whole call stack. You can also view this hierarchy from the perspective of "worst bottleneck" functions, ordered either by execution time or memory allocation.

For me, JProfiler is one of the most important tools in my development process (second only to Eclipse).


Also: there's a free 10-day trial. Download it and check it out. And, btw, I'm not affiliated with the company or anything. I've just been a happy customer for the last five or six years.

like image 172
benjismith Avatar answered Sep 18 '22 00:09

benjismith


I am not familiar with offline profiling. Isn't it what hprof is for?. Otherwise I've had very good experience with YourKit profiler.

like image 28
Peter Severin Avatar answered Sep 19 '22 00:09

Peter Severin