This page last changed on Nov 08, 2010 by stepheneb.

Java Profiling with JIP

This Whitepaper.pdf is a good introduction to JIP and how it works.

The author of JIP also wrote this article: Build your own profiling tool for IBM's DeveloperWorks.

Excerpted from the jiprof page:

Unknown macro: {section}
Unknown macro: {column}
Unknown macro: {column}

JIP is a code profiling tool much like the hprof tool that ships with the JDK. There are, however, a few differences:

  1. Interactivity. hprof is not an interactive profiler. It starts when your program starts and ends when the JVM exits. In many cases this doesn't give you a true measure of performance since the Just In Time compiler doesn't compile code on the first pass. In addition, this type of profiler is not useable at all in web applications since you end up profiling the web container as well as the web application. JIP, on the other hand, allows you to turn the profiler on and off while the JVM is running.
  2. No native code. Most profilers have some native component. This is because most profilers use the JVMPI (Java Virtual Machine Profiling Interface) which requires the use of native components. JIP, however, is pure Java. It takes advantage of the Java5 feature which allows you to hook the classloader. JIP adds aspects to every method of every class that you want to profile. These aspects allow it to capture performance data.
  3. Very low overhead. Most profilers are very slow. In many cases hprof will cause a program to run 20 times slower. JIP, on the other hand, is lightweight. A VM with profiling turned on is about twice as slow as one without a profiler. When the profiler is turned off, there is almost no overhead associated with using JIP.
  4. Performance Timings. JIP gathers performance data. You cannot use most profilers to do timings of your application. hprof, for example, will show you the relative amount of time that is spent in different parts of your code, but hprof has so much overhead, that you cannot use it to get real world timing measurements. JIP, on the other hand, actually tracks the amount of time used to gather performance data and factors that time out of its analysis. This allows you to get close to real world timings for every class in your code. So there is no need to litter your code with System.currentTimeMillis()!
  5. Filters by package/class name. One of the annoying things about hprof is that there is no way to filter out classes by class or package name. JIP allows you to do just that (for more information, look at the file). This in not to say that the execution time is not included. It is included but can only be seen in the execution time of the calling routine.
Unknown macro: {column}

Using JIP with Eclipse:

Here's what I did to get JIP working with Eclipse:

  1. Downloaded and extracted the JIP 1.1.1 binary zip distribution:
  2. Copied: jip/profile/ => jip/profile/
    I changed these three values in
  3. Made a new JVM in eclipse and set the JVM parameters to startup JIP and specify where the results are saved.
    1. Copied Java 1.5.0 (MacOS Default). (From Preferences > Java > Installed JREs)
    2. Gave it new name Java 1.5.0 + JIP
    3. Set the Default VM Arguments to (split onto two lines for confluence):

To use the profiler just specify this Alternate JVM in the eclipse launch settings for your application.

After running the application I viewed the results like this:

$ java -jar client/jipViewer.jar /Users/stephen/Desktop/profile.xml

You can see more information about how this worked profiling an OTrunk activity here: OTrunk Profiling.

References: Painless Java Profiling using JIP

Profiling only certain ClassLoaders or specific classes.

You can use the JIP properties file to specify a ClassLoaderFilter which will limit JIP profiling to a subset of ClassLoaders. JIP comes with ClassLoader filters for WebApps, AntTask, JBossEJBC, JBossServlet. and JBossUniversal.

A ClassLoaderFilter can also specify the set of ClassLoaders to filter by specifying the interface they implement.

Packages or classes can also specifically be included or excluded from filtering.

Dynamically turning profiling on and off.

JIP can be used with an external remote control to turn profiling on and off dynamically.

This is enabled by changing values in the jip properties file and running

to control JIP in your running application.

JIP can also be turned on and off programmatically.

Whitepaper.pdf (application/pdf)
Document generated by Confluence on Jan 27, 2014 16:56