[seam-dev] How to reduce UserTransaction lookups
Jay Balunas
tech4j at gmail.com
Fri Oct 3 17:35:32 EDT 2008
I took a quick stab at a fix for the transaction lookup problem. I will
create a related jira for this issue, so that we can track it and resolve it
for Seam 2.1.1.
All of the JNDI requests for UserTransaction go through the
org.jboss.seam.transaction.Transaction class (see :
http://fisheye.jboss.org/browse/Seam/trunk/src/main/org/jboss/seam/transaction/Transaction.java?r=5875).
This is an event scoped component so its lifecycle covers the entire
request from RESTORE_VIEW through RENDER_RESPONSE.
I modified it (see attached patch file) so that it stores the result of the
transaction lookup (UserTransaction, EjbTransaction, or NoTransaction). It
then returns this result the next time a transaction is requested.
This drastically cuts down the number of JNDI lookups. For the wiki user
forum front page the number of lookups went from 114 to 6!! One at the very
start of the RESTORE_VIEW phase. Then the 5 others are after the
REDER_RESPONSE phase. I'm assuming because of ajax related calls for
caching.
I ran this change through the 25 and 50 user performance runs and saw a
small increase in performance, but I have not yet investigated the details
in the profiler to determine exactly where we are spending the time now. I
would guess that we are not not blocking as heavily on the InitialContext
lookups, but instead are passing through that code quickly and hitting
further blocks, or processing bottlenecks in the persistence layer.
I looked a bit at using synchronizations in an attempt to clear the stored
value if the transaction is completed during the event scope but I ran into
some issues with that. The current approach seems to working fine, and the
wiki behaves normally, but I wanted to get some more opinions on this
What is the risk of caching this transaction instance in the event scope?
How can we determine when/if the transaction is not valid anymore - do we
need to?
Does the behavior need to be different for UTTransaction vs CMTTransaction?
Thanks,
Jay
--
blog: http://in.relation.to/Bloggers/Jay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/seam-dev/attachments/20081003/47f8f391/attachment.html
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Transaction.txt
Url: http://lists.jboss.org/pipermail/seam-dev/attachments/20081003/47f8f391/attachment.txt
More information about the seam-dev
mailing list