JSF Profiling with TPTP

Leave a comment

November 2, 2010 by huionn

After running JBoss Seam in production mode (core debug=”false” and facelets development=”false”), I found that rendering of RichFaces ExtendedDataTable is still quite slow – it takes between 150 to 220 ms to render the table in RENDER_RESPONSE phase.

Today I spent one whole day to profile the JSF pages.

At first I used jvisualvm bundled with Java 6 to profile the pages. It is very easy, but I am unable to get much insight in the cause to slow rendering (may be due to my ignorance). In addition, I am unable to use jvisualvm with JBoss Application Server. The JBoss seemed like freezing forever when I start profiling. So, I can only profile a sample RichFaces application in Jetty.

Later, I tried to install Eclipse Test and Performance Tools Platform (TPTP). However installation and profiling with TPTP is not straightforward.

Following the instrustion in TPTP http://www.eclipse.org/tptp/, as I am using Eclipse 3.5.2, so I download TPTP-4.6.2 all TPTP plugins and extract the zip file into eclipse folder. After that, I can profile Java application run from eclipse. Hmmm, everything went smoothly.

According to the site, TPTP support WTP. So I tried to profile JBoss Application 5.1, but no monitor to select. I thought there is something wrong in my configuration. Then I read from a blog that Agent Controller is required for profiling JBoss (in TPTP website, it mentioned that Agent Controller is included in TPTP plugins – but it is still required for standalone application such as Application Server – I misread it).

After setup Agent Controller as instructed, the problem still persisted. Then its help show that only JBoss 4.x is support in this version. Sigh…

(I almost gave up at this point…) With little googling, I found that I still can profile Application Server by attaching to remote profiler agent http://edgblog.wordpress.com/2007/11/21/profiling-a-jboss-app-with-eclipse-tptp/. So, I tried to run JBoss Application Server with -XrunpiAgent:server=enabled JVM parameter. Then server failed to start with error that it could not find piAgent lib (although I have included the <path_to_piAgent.dll> into System Path). After some trial and error, I found that doublebclick JBoss Runtime Server > Open launch configuration > Environment > Path = native which is somehow incorrect.

I changed it to ${env_var:PATH} and it could proceed…

until it showed the error that Java Virtual Machine Profiler Interface (JVMPI) is no longer supported in Java 6. I thought I had to give up then.

I found that the newer TPTP also supports JVMTI with instructions in <agntctrl>\plugins\org.eclipse.tptp.javaprofiler\readme.txt.

Finally, TPTP works with JBoss AS. This is definitely most troublesome experience in this month. (snapshot below is from sample extendeddatatable in Jetty. It is quite different with my JBoss application where javax.faces.component.UIComponentBase is taking relatively more time.)

I think TPTP is better in providing sensible view of collected statistics. By viewing the top 10 base time of methods, I think that is the time required to parse the components in facelets template and render the output (html, JS, etc).

(The Base Time shown is much longer than actual time because overhead of Java classes instrumentation is significant when numbers of calls are high. This may distort the actual cause of slow rendering but I have to assume that it is correct at the moment.)

In conclusion, in order to validate the performance, I have to load test to see the throughput of application. By the ways, in practice, database access is the bottleneck for enterprise applications most of the time.


[UPDATE] After retrying with jvisualvm, I noticed that there are plenty of warning like

Profiler Agent Warning: Failed to lookup cached class com/sun/facelets/util/FastWriter
Profiler Agent Warning: Failed to lookup cached class org/richfaces/model/Field
Profiler Agent Warning: Failed to lookup cached class org/richfaces/model/FilterField

which mean dynamic class instrumentation used by jvisualvm has limitation. This explained why I was not able to get informative statistics from jvisualvm.

Despite being less convenient, startup time agent-based class instrumentation is more reliable.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: