Profiling GlassFish 3 with JProfiler

Recently, I investigated performance issues of GlassFish 3. I found that JProfiler 6 is a very handy tool. In this blog, I would like to share with you what I learnt. I would like to thank Dhiru Pandey and Suveen Nadipalli for their help. In the following, we will assume GlassFish 3 installed in $GLASSFISH_HOME and JProfiler 6 is running on Mac OS 10.5.8.

Set up GlassFish 3

Insert com.jprofiler.agent, com.jprofiler.agent.*, immediately after ${eclipselink.bootdelegation}, in org.osgi.framework.bootdelegation property in $GLASSFISH_HOME/glassfish3/glassfish/osgi/felix/conf/config.properties.nojaxb.

Note that if one were to debug the GlassFish Web Profile - they would need to change $GLASSFISH_HOME/glassfish3/glassfish/osgi/felix/conf/config.properties.

Issue 12364 is filed on this. Once this bug is fixed only config.properties will need to be modified.

Set up JProfile 6 with GlassFish 3

  1. Launch JProfiler.
  2. In Quickstart menu, choose "An application server, locally or remotely".
  3. Choose integration wizard: choose "Glassfish V3".
  4. Choose profiled application located: "On this computer".
  5. JVM settings: (vendor/version/mode). (Note that GlassFish 3 uses JDK "1.6.x".)
  6. Choose "Wait for connection from the JProfiler GUI".
  7. Locate the config file: $GLASSFISH_HOME/glassfish3/glassfish/domains/domain1/config/domain.xml.
  8. Locate the start script: $GLASSFISH_HOME/glassfish3/glassfish/bin/asadmin.
  9. Choose the jprofiler port: 8849 (default).
  10. Click "No".
  11. JProfile create a script asadmin_jprofiler in $GLASSFISH_HOME/glassfish3/glassfish/bin. In Mac, you may like to double check that the script has execution permission. Run chmod u+x $GLASSFISH_HOME/glassfish3/glassfish/bin/asadmin_jprofiler if necessary.
  12. Click "Start Center" > "Open Session" > Double click "Glassfish V3 on localhost" > Session Startup: "Cancel"
  13. Click "Session Settings" > "Filter Settings" > "Excluded"
    Make sure that you do not exclude the classes that you want to profile. For instance, I remove "com.sun.", "org.glassfish.", "org.apache.", "org.jvnet". Click "OK" to save it.
  14. Click "Start" for start profiling GlassFish 3.
  15. For collecting performance data, "CPU Views" > Press to record CPU data

Tips for Viewing and Analyzing Data

  1. For a given class, the most time consuming method is the first one. In general, one may like to look at the most expensive operation first.
  2. If one only interests only in profiling certain package, then one can enter the package name in "View Filters" text box near the bottom of the JProfile screen.
  3. One can export the tree view of the data into html by clicking "Export" in top menu bar.
  4. One can save the data for later comparison by clicking "Save Snapshot".
  5. One can open and compare several snapshots at the same time as follows:
    • "Session" > "Open Snapshot" > "New Window"
    • Select the snapshot data file (with extension .jps) > "Open"

Can we profile GlassFish 3 with JProfile 5?

One can profile GlassFish 3 with JProfile 5. The setup for GlassFish 3 is the same. The setup for JProfile 5 is as follows:
  1. Launch JProfiler.
  2. Close Quickstart if necessary.
  3. Click "Start Center" > "New Session".
  4. Fill in the following information and click "OK".
    • Enter the "Session name".
    • Choose "Session Type": Local.
    • Java VM: 1.6.x
    • Working Directory: $GLASSFISH_HOME/glassfishv3/glassfish/domains/domain1/config
    • VM arguments:-Dcom.sun.aas.installRoot=$GLASSFISH_HOME/glassfishv3/glassfish -Dcom.sun.aas.instanceRoot=$GLASSFISH_HOME/glassfishv3/glassfish/domains/domain1
    • Main class executable JAR: $GLASSFISH_HOME/glassfishv3/glassfish/modules/glassfish.jar
  5. Then repeat Step 12 to Step 15 of the setup for JProfile 6 above.

Enjoy profiling GlassFish 3.

Comments:

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

Shing Wai Chan

Search

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