Free Sun Studio 12, and NetBeans Profiler

Ok ... so what does Sun Studio 12 have to do with NetBeans and the NetBeans Profiler ?

Sun Studio 12 is built on NetBeans.

But, isn't Sun Studio 12 for native languages?

Not exclusively, no.

There are two programs which are part of Sun Studio which I use quite often and find very useful in my Java development.  They are called Collector & Analyzer.   The Collector collects performance / profiling data into a what is called an experiment file and the Analyzer is a program that reads the experiment file.

Aahh, so the Collector / Analyzer is a competitive product to the NetBeans Profiler?  No, not exactly.  In fact they compliment each other rather well.

I find the Collector / Analyzer very useful as the first tool in profiling a Java application.  By default the Collector samples a running Java application once per second and includes in its profiling data not only user cpu time and system / kernel cpu time, but also lock contention information, (amongst quite a bit more information).

I find the Collector / Analyzer is very good at giving me a very quick high level view of the performance of a Java application.   Where I like to use the NetBeans Profiler is once I have found an area, or a couple areas of interest, by using the Collector / Analyzer, I use the NetBeans Profiler to instrument specific methods or call points.   Hence, the ability to focus on specific areas of an application is what I find is the NetBeans Profiler's strong point.

Back to the Collector / Analyzer .... A couple additional things it can do ...

Finding contended locks which are performance & scalability "blockers" in a Java application can be a difficult task.  But, Sun Studio's Collector / Analyzer makes this task much easier.  It can display the amount the time spent waiting to acquire Java locks.  Not many profilers can do this and this is one of my favorite features of Collector / Analyzer.

You can also narrow the scope of the profiling run to a specific set of samples.  So, if your application goes through a startup phase you can eliminate those samples from the collected data.

In addition to looking at Java methods, you can also get information about how the JVM, i.e. HotSpot, is performing.  That's right you can see HotSpot method information too.  And, on Solaris Sparc and Solaris x86 (this may be available on Linux too?) you can view the assembly language instructions generated by the JIT compiler for given Java methods.  Perhaps not that interesting to most Java developers.  But, it can be interesting to those of us who are performance junkies :-)

Have I peaked your interest?

How easy is Collector / Analyzer to setup and configure?

It's as easy as a Sun Studio 12 download, installation, adding the <install dir>/bin directory to your PATH and then starting your Java application with:  collect -j on <your old Java command line>.  For instance, if you were running a Java command line such as,  java -server -jar Java2Demo.jar,  you would simply start the collector by issuing a command line of, collect -j on java -server -jar Java2Demo.jar.

Running the collect command will automatically create an experiment file in the directory where you launched the collect command.  The file name will be of the form, test.#.er where # begins at the number 1 and increments as needed as you run more collector experiments.

Once you've completed the execution of your Java program, you open the experiment file, the test.#.er file, using the Analyzer which is as easy and typing, analyzer at the command line, (assuming you have the <install path>/bin directory in your PATH).   You simply open the experiment file with the Analyzer.   From there you can choose to "Filter Data", add additional columns of data to the display to include sys time and lock time, etc.

Perhaps you should try it out for yourself ... A free download is available at: http://developers.sun.com/sunstudio/downloads/index.jsp

There's additional information on how to use Sun Studio 12 and the Collector / Analyzer at:
http://developers.sun.com/sunstudio/

Enjoy!


Powered by ScribeFire.

Comments:

Have you ever used the Sun Studio collect command with an application server? It seems like you would have to modify the server's startup script, right? Further, how do you eliminate all the "noise" from the server initialization etc. so that you can see what is happening in one of the deployed applications?

Posted by Gregg Sporar on July 06, 2007 at 06:15 AM CDT #

Gregg ... there's a couple ways you can use Sun Studio collect command with an application server. I find the easiest way to do this is, as you suggested, modify the application server's startup script. For users of GlassFish, it is not so obvious what script to modify. What I do is modify the <install dir>/domains/domain1/bin/startserv script so that it prepends the 'collect -j on' ahead of the $JAVA command line at end of the script. Also note you may have to explicitly set JAVA_HOME to point to the JVM you want to use and also check that NATIVE is \*not\* set to "native". For the second part of your question ... how do you eliminate the "noise" from the server initialization etc. You actually do this within the Analyzer. The Collector will collect data for the entire time the jav a process is running. When you load the experiment file, which is what the collect command generates, you can filter the data samples collected to view a subset of samples. For example, let's say you know it takes 15 seconds for your application server to launch and you know you waited about another 5 seconds to deploy your application. Further assume your deployment took 5 seconds. Then you began to exercise your application and you exercised the application for 5 minutes before shutting down the application server. By default the collect command will sample every 1 second. So, we know that if we can ignore at least the first 25 samples collected and possibly ignore the last 20 or so samples collected we'd have a subset of samples that represent when we were stressing the application. We can take that information when we load the experiment file in the Analyzer, this is the 'analyze' command, go to the 'Filter Data' icon, the one that looks like a funnel, (or use the View > Filter Data menu) and tell it to only present the data for samples between 25-125, (i.e. ignore the first 25 seconds and ignore the last 20 seconds of the 2 minutes performance stress test). Click the Apply button and we now have filtered out the startup, deployment and shutdown noise. Also, notice that you can view Sys Time, Waiting For Locks and other data too from the View > Set Data Presentation menu. As I mentioned in the blog, waiting on locks in one of my favorite capabilities of this tool. Hope that help ... and thanks for the question :-)

Posted by huntch (aka charlie hunt / charlie brown) on July 06, 2007 at 06:42 AM CDT #

Post a Comment:
Comments are closed for this entry.
About

charliebrown

Search

Top Tags
Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today