Binu John's Weblog
Profiling GlassFish V2 using Sun Studio
In one of my earlier blogs, I had mentioned that Collector/Analyzer within Sun Studio is my primary performance analysis tool. It would have been nice if we could collect GlassFish V2 profiles using Collector by following a few easy steps. Unfortunately, this is not the case. You will have to go through a couple of convoluted steps:
- Start the domain and then capture the entire 'java .... PELaunch start' command.
- Create a password file containing the following information, each in a separate line - <admin user>, <admin password>, <master password>
- Start the collect command as follows: collect -j on -y WINCH -d result_dir java_command < password_file
The 'WINCH' signal is used to specify when to start and stop the profile collection. In most scenarios, you want the collection during the steady state of the benchmark run. So you would typically wait for the ramp up time to complete, before starting profile collection using the kill -WINCH <pid> command. Since this is a sampling collector, it is advisable to collect the profile for a longer duration (I typically use 20 minutes). You can stop collection using the kill -WINCH <pid> command.
I have written a script that makes this process much easier. It is given below.
| #!/bin/sh if [ $# -lt 5 ] then echo Usage $0 AS_HOME SUNSTUDIO_HOME RESULT_DIR DOMAIN PASSWORDFILE echo AS_HOME: Root directory of GlassFish echo SUNSTUDIO_HOME Root directory of Sun Studio installation echo RESULT_DIR: Directory to store experiments echo DOMAIN: Domain name echo PASSWORDFILE: Password file. A Simple file with the following information, each on a separate line - Admin user, Admin password, Master password. A sample password file has been created at /tmp/password echo admin > /tmp/password echo adminadmin >> /tmp/password echo changeit >> /tmp/password echo Example: $0 /export/glassfishv2/glassfish /opt/SUNWspro /results domain1 /tmp/password exit fi AS_HOME=$1 COLLECT=$2/bin/collect RESULT_DIR=$3 DOMAIN=$4 PASS=$5 os=`uname` if [ $os = "SunOS" ] then AWK=nawk elif [ $os = "Linux" ] then AWK=gawk else echo "Unsupported OS" exit fi mkdir -p $RESULT_DIR AS_JAVA=`grep AS_JAVA $AS_HOME/config/asenv.conf | grep -v \# | $AWK -F= '{print $2}' | $AWK -F\" '{print $2}'` # Check if the domain is running. pid=`$AS_JAVA/bin/jps | grep PELaunch | grep -v grep | $AWK '{print $1}'` if [ "pid$pid" != "pid" ] then echo An instance of the app server is running. Please shut it down first. exit fi echo This may take a minute. Please be patient.... echo Starting $DOMAIN to access java command $AS_HOME/bin/asadmin start-domain $DOMAIN > /dev/null echo .... sleep 10 pid=`$AS_JAVA/bin/jps | grep PELaunch | grep -v grep | $AWK '{print $1}'` cp=`$AS_JAVA/bin/jinfo $pid 2> /dev/null | grep java.class.path | $AWK -F= '{print $2}'` props=`$AS_JAVA/bin/jinfo -flags $pid 2> /dev/null| grep '\-D'` echo Stopping $DOMAIN $AS_HOME/bin/asadmin stop-domain $DOMAIN > /dev/null echo .... sleep 10 echo Starting domain in collect mode $COLLECT -j on -d $RESULT_DIR -y WINCH $AS_JAVA/bin/java -cp $cp $props com.sun.enterprise.server.PELaunch start < $PASS & echo .... sleep 10 pid=`$AS_JAVA/bin/jps | grep PELaunch | grep -v grep | $AWK '{print $1}'` if [ "pid$pid" = "pid" ] then echo Error is starting GF is collect mode, refer to domains log file - $AS_HOME/domains/$DOMAIN/logs/server.log else echo "AS Process Started, pid=$pid. Execute the following command to start and stop profile collection" echo "kill -WINCH $pid" fi |
Running the script without any parameters prints out the usage.
| #./start_collector.sh Usage /home/binu/projects/perf-book/benchmarks/start_collector.sh AS_HOME SUNSTUDIO_HOME RESULT_DIR DOMAIN PASSWORDFILE AS_HOME: Root directory of GlassFish SUNSTUDIO_HOME Root directory of Sun Studio installation RESULT_DIR: Directory to store experiments DOMAIN: Domain name PASSWORDFILE: Password file. A Simple file with the following information, each on a separate line - Admin user, Admin password, Master password. A sample password file has been created at /tmp/password Example: /home/binu/benchmarks/start_collector.sh /glassfish /SUNWspro/bin/collect /results domain1 /tmp/password |
The experiments are stored in the folder, RESULT_DIR/test.x.er (where x is a number). The profiles can be viewed using 'analyzer' as follows -
#$SUNSTUDIO_HOME/bin/analyzer $RESULT_DIR/test.x.er
While anaylzing results, it is a good practice to set the data presentation format to expert mode. This can be set by selecting View --> Set Data Presentation. In the pop up window, select the Formats tab and click on Expert in the View Mode. More information about performance analyzer can be found here.
Downloads
Posted at 03:10PM Oct 16, 2008 by binu in GlassFish |