Saturday, May 4, 2013

Profiling ATG CRS application using VisualVM

As and when order were huge, Modification of order took long time, of course right. But I wanted to get some metrics to get an idea. And I was surprised to find that ATG OOTB CartModifierFormHandler.java was missing hooks to Performance Monitor. So I went the route to use JVisualVM that comes default with JDK 1.6.

Step 1) Open VisualVM, navigate to Profiler tab and modify settings similar to the picture below.



Step 2) Add Java6-server.profile file to %JAVA_HOME%\lib. I did not have the file on my machine, I downloaded a copy from https://issuetracker.springsource.com/browse/DMS-424?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel and added one line "org.netbeans.lib.profiler.*"

Step 3) Restart Jboss and open Jboss process in Visual VM

Step 4) Open your favorite browser and navigate to a product details page assuming you want to profile adding item to cart (don't click add item to cart yet)

Step 5) Go to Profiler Tab and then click on button "CPU", wait for about 3-4 secs until you see a message similar to  "profile running(256 methods instrumented)"

Step 6) Now click on CRS application, "Add to Cart" button (make sure you select Color and Size

Step 7) First time it takes long time to capture statistics, be patient. Once done, you can click on snapshot and save it for investigating later. Don't rely on the first time statistics repeat this step by resetting statistics and adding another item to cart. Then metrics should look like


Note:
1) on the command prompt where you start Jboss, make sure you run the command
    SET JBOSS_CLASSPATH=%JAVA_HOME%\lib\visualvm\profiler\lib\jfluid-server.jar;%JBOSS_CLASSPATH%

  if not you will see error in jboss server log
"org.netbeans.lib.profiler.server.ProfilerRuntimeCPUFullInstr.rootMethodEntry(ProfilerRuntimeCPUFullInstr.java:284)"

2) if you don't run Step 2 mentioned above, you will see in Server log

ArrayIndexOutOfBoundsException and Profiler Agent Error: Redefinition failed

3) If you leave org.jboss in starter class in profiler settings, then it will take long. It is good practice to have right classes in settings according to the scenario you are interested to profile. In the case above I wanted to profile "Adding Item to Cart"

Download java6-server.profile here

No comments:

Post a Comment