Skip to main content

Looking as deep as possible with JBoss Profiler

Posted by edgars on June 13, 2007 at 10:22 PM PDT

I will show you now how you can use JBoss Profiler as your default choice for pre-production profiling tests.

Step 1 - Download the JBoss Profiler

Go to the JBoss Profiler Project page here, and download the CR4 Version from that page

Step 2 - For Linux Users

Copy to /usr/lib the file from /jvmpi/linux. You should put on this folder, because for Linux it works as Windows/System, so for Windows users, please copy the .dll file from jvmpi/windows into your System folder.

Step 3 - Testing your Java Library Loading

You can test if Java is really loading our profiler Library, to do that execute the following command line in console:

[root@esilva jdk1.5.0_12]# java -XrunjbossInspector:/tmp Foo
Running process 9330
Exception in thread "main" java.lang.NoClassDefFoundError: Foo

If you see on the screen a result like that, you library is working fine.

Step 4 - Deploying a Spring Sample: countries.war for Profiling issues

After to build the sample using ANT, I copied the war file to my JBOSS_HOME/servers/default/deploy and that´s all! It is ready to be deployed.

Step 5 - Deploying the profiler Agent into JBoss AS

Go to JBOSS_PROFILER_EXTRACTED_FOLDER and from there, copy to JBOSS_HOME/servers/default/deploy the file: jboss-profiler-noAOP.sar. This is a JMX agent, which could be useful for you. Don't forget to deploy the jboss-profiler.war file into JBoss as well.

Step 6 - Setting JAVA_OPTS enviroment variable and starting JBoss

We will check what happens with class inside packages beggining with org.springframework , in addition the profiler will keep the results into a folder located in /opt/profiledata. So to make it possible, we must export the variable JAVA_OPTS, and after this we can run JBoss AS.

Declaring JAVA_OPTS:

  export JAVA_OPTS=-XrunjbossInspector:/opt/profiledata,include=org.springframework,ignore=*,

And after you can start JBoss using the command ./ from folder JBOSS_HOME/bin.

As sooner you see JBoss starting, you will see a proccess identifier, this number will be useful for us to start the profiling task.

Step 7 - Profiling the Application

I prefer the hard-core way to start to profile the Application, first of all you must go to the command-line window, and type:

 ps ax

You will see a resulting screen as the following:
 7865 pts/0    S+     0:00 /bin/sh ./
7888 pts/0    Sl+    5:44 /opt/jdk1.5.0_12/bin/java -serv
8011 pts/1    S      0:00 su
8014 pts/1    S      0:00 bash
9928 ?        S      0:00 pickup -l -t fifo -u
10061 ?        Z      0:00 [ifconfig]
10062 pts/1    R+     0:00 ps ax
[root@jsilva jdk1.5.0_12]#

So, you if you are using Sun's JDK you might use the kill -3 command in the proccess number 7888, and than if you go to the other screen where you can see JBoss output, you will see profiler initializing. Than the full syntax is the following:
kill -3 7888

And then, in the JBoss output window you will see messages like the followin:
ContendedEnter ThreadId -1428133384 681764947
ContendedEnterED ThreadId -1428133384 681764949
ContendedEnter ThreadId -1428133720 681764949
ContendedEnter ThreadId -1428133832 681764949
ContendedEnterED ThreadId -1428133832 681764950
ContendedEnterED ThreadId -1428133720 681764951
ContendedEnter ThreadId -1428133944 681764952
ContendedEnter ThreadId -1428134056 681764952
ContendedEnter ThreadId -1428134280 681764952
ContendedEnterED ThreadId -1428133944 681764952
ContendedEnterED ThreadId -1428134280 681764952
ContendedEnterED ThreadId -1428134056 681764952
ContendedEnter ThreadId -1428133944 681765959
ContendedEnterED ThreadId -1428133944 681765960
ContendedEnter ThreadId -1428134280 681766962
ContendedEnterED ThreadId -1428134280 681766963
ContendedEnter ThreadId -1428133944 681766966
ContendedEnterED ThreadId -1428133944 681766966
ContendedEnter ThreadId -1428133720 681767971
ContendedEnterED ThreadId -1428133720 681767972
ContendedEnter ThreadId -1428133608 681768978
ContendedEnterED ThreadId -1428133608 681768978

You profiler is running, so go to the Application http://localhost:8080/countries and try to do some simple tests.

If you wanna stop Profiler, please call the kill -3 process # again, and than on the folder you had selected on the JAVA_OPTS variable contains many files which profiler will proccess and show you the results.

Now, it's time to see the JBoss-Profiler User Interface, so type http://locahost:8080/jboss-profiler and than you will see the Profiler UI, click in the Runtime Profiler link and inform the folder where profiler is actually storing the informations, in our case: /opt/profiledata and click next. See the image 1:


Image 1 - The Profiler Initial Screen

And then inform the proccess number,in the next screen:


Image 2 - Getting a specific process execution

After the processing phase, you will able to identify some drawbacks into your Application. See the last image as an example:


I hope it could be as useful for you as it have been these last days for me! See you!

Related Topics >>