Monday, August 18, 2008

Project is finished! Let's start bug fixing session =) ?

As JIP profiler doesn't provide memory analyzings, I made a decision to search for another one. I decided to use profiler4j ( because it is very similar to JIP profiler (pure java, hooks the classloader, "on the fly" connection), but also has memory analyzing tool. The tool doesn't provide the full information about objects in the heap, but draws intelligible plot about memory consumption. The minus of the project is that it is only on beta stage and can contain bugs (I fixied one about comparing method results while integrating it).

Another candidate for integration was TIJmp ( profiler, this one is using new native profiling library JVMTI, and seems to be more efficient than previous versions on JVMPI, but I didn't find there any ability to get timings, so I used profiler4j for integrated profiler.

I want to say that my project was to get bundle separated results for timings and memory. Timings are ok, I can filter the invoked methods by package and then display the results. But with memory I cannot get such results. Moreover all the profilers I used hadn't the ability to get the representation of objects allocation in heap from an invoked method. Only profiler where you can get similar info was netbeans profiler (, it uses SUN's JFluid technology which is experemental and not opened. So the function is needed to be researched and developed, may be it could be a good topic for a Master Thesis. So I used a plot to represent graphically the memory allocation which is also very helpful I think.

I also decided to use in plugin thread profiling, call graph allocation and class filtering options, because they don't slow significantly SC work and are provided by the profiler4j.

Plugin Tutorial

1.Make a new project from performance branch.

2.Assert you use JVM 1.5.0_04+

3.Start SC with ant tasks rebuild, run-with-profiler. SC will be started with the profiler's agent which hooks the classloader and listens on port 7890 for profiler's plugin connection establishment.

4.Profiler plugin is placed into Tools menu -> profiler4j

5. Then the console will establish the connection with the agent and load up filtered classes. In our case that will be all the classes in package only exlusion will be package because it's a sin ;-) to profile the profiler.

6. Plug-in's window will appear after the connection.

7. I modified a little bit the example plugin, I added there a button and the button's action listener where I make the thread sleep for 3000 millis. Then I click the test button, go to the profiler's window and click on the snapshot icon (camera) and there goes the results of call tree. The results are bundle separated, we can profile other budles, take snapshot and see the timings. The algorithm for profiling is quite simple: you make actions on the bundle(s) and then take a snapshot. It is also possible to resent timing by clicking on "Reset counters" button.

8. We can also see the detailed method invocations using call graph tab.

9. Memory Tab represents graphical plots for heap and non-heap memory consumption, the plots are uptated every second. We can also run the garbage collector (GC) by clicking on GC button.

10. On Threads tab we can get information about threads, the information is needed to be refreshed manually (refresh button). The displaying information is not bundle separated, it is about all the threads in the SC

11. Class list tab provides you inforamtion about all the classes in classloader. The tab is handy when you want to apply filters on packages.

12. Filters can be applied in Profiling Project Details window. The filter is invoked by clicking on "edit profiling project details" button (a pencil).

13. In help menu you can see some tips about using the profiler.

14. Also you can find there some information about the profiler ;)

In conclusion I would like to thank my mentors, profiler4j developer Antonio S. R. Gomes and other developers for their advices and help. I hope the plug-in will be useful for the SC developers.