JIP — The Java Interactive Profiler

  SourceForge.net Logo

What is JIP?

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 profile.properties 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.

How to use JIP

Note: JIP requires a Java5™ VM.

To run the profiler, you need the following:

These files are loaded by the application classloader and should not be in the extentions loader path. The jar files need to be in the same directory. The properties file can be anywhere.

To use the profiler, you need to use the following JVM arguments:

-javaagent:[DIR]\profile.jar -Dprofile.properties=[DIR2]\profile.properties
where [DIR] is the directory that contains the profile.jar
Note: Due to a bug in the JDK on OS X, [DIR] must be a fully qualifed path.
and [DIR2] is the directory that contains the profile.properties

By default (if you don't give a -Dprofile.properties), profiling starts out turned on and the remote interface (use to profile interactively) is turned off (see the profile.properies for more information). In this case JIP works just like hprof, although it is much faster.

When using with stock Tomcat, set the java agent by using the env. variable JAVA_OPTS. For example, on Windows™ use the following:

SET JAVA_OPTS=-javaagent:[DIR]\profile.jar -Dprofile.properties=[DIR2]\profile.properties
Where [DIR1] and [DIR2] are described as above.

Interactive profiling

In some cases, like webapps, you probably want to start out with the profiler turned off. When you get to some case you want to test, you'd like to turn it on, run the test case, turn the profiler off and dump the results. To do these things, you first of all need to change the profile properties file:

To interact with the profiler you need the client.jar which is in the /client directory of the JIP distribution. In my personal experience with webapps, you should exercise a test case at least six times before trying to measure performance. Presumably this is because the Just In Time compiler will observe how the code is used a number of times before compiling it into native code.


There are some examples of how to use JIP: example.bat, example-ant-1.5.sh and example.sh. All use the example of compiling JIP with ant. example.bat and example-ant-1.5.sh work only with ant 1.5 and example.sh works only with ant 1.6 (this is because the way that ant gets invoked changed between the two releases).


JIP can be downloaded from SourceForge.

Copyright 2006