Posted on 2008-08-21 09:27:00.0 by Edgar Ankiewsky Silva
[ View original post ]
This entry will show how start use the jboss-profiler beta2, first of all , download the software from here:
http://www.jboss.org/downloading/?projectId=jbossprofiler&url=/jbossprofiler/downloads/jboss-profiler-2.0.Beta2.tar.gz , save in some folder in your disk and unzip it.
Once you have the files in your disk, basically to setup jboss-profiler you will have to do the following steps:
- Copy jboss-profiler.jar to jbossas/bin
- Copy jboss-profiler.properties to jbossas/bin
- Edit jboss-profiler.properties in jbossas/bin to include the classes to be profiled
- Copy jboss-profiler-plugins.jar to jbossas/bin
- Edit run.conf (Unix) or run.bat (Windows) in jbossas/bin to include JBoss Profiler in JAVA_OPTS ( See you run.conf and add use this example: JAVA_OPTS="-javaagent:jboss-profiler.jar -Djboss-profiler.properties=jboss-profiler.properties -Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000")
- Copy also to jbossas/bin the javaassist.jar if you are using JBoss AS 4.2.x
- Copy jboss-profiler.sar to jbossas/server//deploy
- Boot application server, if the following log appears everything is ok:
========================================================================= JBoss Bootstrap Environment JBOSS_HOME: /opt/java/jboss/profiler/as JAVA: /opt/java/jdk1.6.0_03/bin/java JAVA_OPTS: -Dprogram.name=run.sh -server -javaagent:jboss-profiler.jar -Djboss-profiler.properties=jboss-profiler.properties -Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.net.preferIPv4Stack=true CLASSPATH: /opt/java/jboss/profiler/as/bin/run.jar:/opt/java/jdk1.6.0_03/lib/tools.jar ========================================================================= JBoss Profiler 2.0.Beta2 (Sun Microsystems Inc. 1.6.0_03) JBoss Profiler depends on external communication module 10:55:51,681 INFO [Server] Starting JBoss (MX MicroKernel)... 10:55:51,707 INFO [Server] Release ID: JBoss [Trinity] 4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139)Profiling your Application with JBoss Profiler beta2In order to show the testing, I will do some profiler in JBPM classes, just to check what is happening behind the scenes. To do that I have to edit the jboss-profiler.properties in jbossas.bin directory to add the reference for JBPM's classes, as which is: org.jbpm.* (includes=org.jbpm.*).
Actually JBoss Profiler uses JMX and MBeans as its infrastructure which allows you profiler either JBoss 4.2.x or future 5.x versions. When you deploy the .sar file, you can see the profiler in the jmx-console as you can see in the following image:

You can do several options using the commands via JMX-Console, or as well as you can use command-line interface. At this moment we will use the JBoss profiler CLI, so go to jboss-profiler2-beta-2-folder/ in your shell (Unix or Win) and type the following command: java -jar jboss-profiler-client.jar , the result will be the following:
[jsilva@jsilva jboss-profiler-2.0.Beta2]$ java -jar jboss-profiler-client.jar
Usage: Client [-h host] [-p port]
startProfiler : Start the profiler
stopProfiler : Stop the profiler
snapshot : Take a snapshot
getSnapshot : Get a snapshot
listSnapshots : List snapshots
clearSnapshots : Clear snapshots
gc : Trigger garbage collection
enable : Enable the profiler
disable : Disable the profiler
load : Load a snapshot
save : Save a snapshot
diff : Difference between snapshots
add : Add classes (repository must be enabled)
remove : Remove classes (repository must be enabled)As far you can see you have all these options to invoke profiler operations, for testing I used the following:
1- java -jar jboss-profiler-client.jar snapshot - Which generated a snapshot.
2-java -jar jboss-profiler-client.jar listSnapshots - Which shows all snapshots I had taken from my App Server.
[jsilva@jsilva jboss-profiler-2.0.Beta2]$ java -jar jboss-profiler-client.jar listSnapshots
1: 21 August 2008 11:23:54:296 -> 21 August 2008 11:24:17:117
2: 21 August 2008 11:39:05:687 -> 21 August 2008 11:39:31:255
3: 21 August 2008 11:41:59:145 -> 21 August 2008 11:43:25:6913- java -jar jboss-profiler-client.jar getSnapshot 3 - Which tells to my client flush in my disk the info about my snapshot number 3, after this if you type a ls (dir for win), you can see the folder with thesnapshot timestamp. Please enter on this folder and list the files and folders again, the results would be something like:
[jsilva@jsilva 20080821114159145-20080821114325691]$ ls
caller classes classes.txt hotspots.txt methods.txt overview.txt packages.txt threadsOn the files above you can see the information about your classes, in my case, I just did some operations with my simple bpm application. Take a look on the overview.txt report content:
From: 21 August 2008 11:41:59:145
To : 21 August 2008 11:43:25:691
Threads:
========
Thread-60 20063.47 ms
Most time:
==========
Count Ms % Method
1 13453.22 67.05 org.jbpm.persistence.db.DbPersistenceServiceFactory#getSessionFactory()
1 6078.74 30.30 org.jbpm.db.hibernate.HibernateHelper#createConfiguration(String, String)
3 134.04 0.67 org.jbpm.configuration.ObjectFactoryImpl#getObject(org.jbpm.configuration.ObjectInfo)
6 116.03 0.58 org.jbpm.configuration.ObjectFactoryImpl#loadClass(String)
1 84.82 0.42 org.jbpm.persistence.db.DbPersistenceServiceFactory#openService()
1 79.14 0.39 org.jbpm.persistence.db.DbPersistenceServiceFactory#getConfiguration()
1 56.08 0.28 org.jbpm.persistence.db.StaleObjectLogConfigurer#wrap(org.apache.commons.logging.Log)
14 29.55 0.15 org.jbpm.calendar.Day#(String, java.text.DateFormat, org.jbpm.calendar.BusinessCalendar)
24 4.53 0.02 org.jbpm.calendar.Holiday#(String, java.text.DateFormat, org.jbpm.calendar.BusinessCalendar)
2 3.51 0.02 org.jbpm.calendar.Holiday#parseHolidays(java.util.Properties, org.jbpm.calendar.BusinessCalendar)
Hotspots:
=========
Count Ms Avg % Method
1 13453.22 13453.22 67.05 org.jbpm.persistence.db.DbPersistenceServiceFactory#getSessionFactory()
1 6078.74 6078.74 30.30 org.jbpm.db.hibernate.HibernateHelper#createConfiguration(String, String)
1 84.82 84.82 0.42 org.jbpm.persistence.db.DbPersistenceServiceFactory#openService()
1 79.14 79.14 0.39 org.jbpm.persistence.db.DbPersistenceServiceFactory#getConfiguration()
1 56.08 56.08 0.28 org.jbpm.persistence.db.StaleObjectLogConfigurer#wrap(org.apache.commons.logging.Log)
3 134.04 44.68 0.67 org.jbpm.configuration.ObjectFactoryImpl#getObject(org.jbpm.configuration.ObjectInfo)
6 116.03 19.34 0.58 org.jbpm.configuration.ObjectFactoryImpl#loadClass(String)
14 29.55 2.11 0.15 org.jbpm.calendar.Day#(String, java.text.DateFormat, org.jbpm.calendar.BusinessCalendar)
2 3.51 1.76 0.02 org.jbpm.calendar.Holiday#parseHolidays(java.util.Properties, org.jbpm.calendar.BusinessCalendar)
1 1.35 1.35 0.01 org.jbpm.util.XmlUtil#parseXmlInputSource(org.xml.sax.InputSource)
Allocations:
============
org.jbpm.db.hibernate.StringMax 149
org.jbpm.db.hibernate.ConverterEnumType 49
org.jbpm.configuration.AbstractObjectInfo 32
org.jbpm.calendar.Holiday 24
org.jbpm.calendar.Day 14
org.jbpm.configuration.FieldInfo 9ConclusionJBoss Profiler 2 is built on top of really cool technologies, such as JBoss AOP and JavaAssist, feel you free to contribute with bug-fixes, documentation or with whatever you think could be valuable for the project, it would be a great chance for joining at a JBoss Project as a contributor, as far the actual contributors: Jesper Pedersen, Clebert Succonic and I are not dedicated as a full-time developers for Profiler, the work you can see as the result is a really big effort that Jesper and Clebert are doing. Beyond simple CLI interface, we are planning 2 really cool news, one of that is a new JBoss Profiler console based on RichFaces and related technologies, besides a Plugin for JBoss Operations Network/RHQ Project as well.
Visit:
http://www.jboss.org/jbossprofiler/
Post to DZone
Post to del.icio.us
Digg this!
Stumble It!