<div dir="ltr">ok great - I have intentionally not updated my svn for performance testing so that day to day changes do not inadvertently effect the tests.<br><br><div class="gmail_quote">On Wed, Oct 1, 2008 at 9:14 AM, Shane Bryzak <span dir="ltr">&lt;<a href="mailto:shane.bryzak@jboss.com">shane.bryzak@jboss.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="Wj3C7c">Jay Balunas wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I have been looking more into the InitialContext and some of the performance issues surrounding it.<br>
<br>
There are really a couple of things to look at. &nbsp;One is how the InitialContext is created, and manged, and the other broad category is how often and what items are looked up? &nbsp;I have investigated the first, and have begun investigating the second.<br>

<br>
InitialContext creation and management<br>
------------------------------------------------<br>
The only location were seam creates and manages the InitialContext is the &quot;org.jboss.seam.util.Naming&quot; class (see: <a href="http://fisheye.jboss.org/browse/Seam/trunk/src/main/org/jboss/seam/util/Naming.java?r=5444" target="_blank">http://fisheye.jboss.org/browse/Seam/trunk/src/main/org/jboss/seam/util/Naming.java?r=5444</a> ). <br>

The properties are set in one location and done only once in the initialization of seam (see: <a href="http://fisheye.jboss.org/browse/Seam/trunk/src/main/org/jboss/seam/init/Initialization.java?r=9116#l915" target="_blank">http://fisheye.jboss.org/browse/Seam/trunk/src/main/org/jboss/seam/init/Initialization.java?r=9116#l915</a> ).<br>

<br>
I see two issues here - one is creating the initial context every single time it is needed, and the other is processing/checking the properties every time it is called.<br>
<br>
The first issue would require some caching mechanism or logic for reuse. &nbsp;I am not an expert on when it makes sense to reuse an instance of the InitialContext, and when we need to get it fresh. &nbsp;I can say that we currently use they exact same properties to initialize it and those are set during Seam initialization and do not appear to ever change once created. &nbsp;Is there a way to cache and optimize this instantiation?<br>

<br>
The second issue is that we do a certain amount of processing every time the context is requested, this could be optimized. &nbsp;Currently I see a few blocked threads on the &quot;props.size()&quot; call in the Naming class which is a synchronized method on the Hashtable. &nbsp;This could easily be avoided. &nbsp;Although we need to maintain the logic that if the property list is empty we continue to call &quot;new InitialContext()&quot; and not pass in the properties object. &nbsp;This is because the first thing the InitialContext constructor does with a properties object is clone it which can be costly. &nbsp;I have attached a patch that implements these changes for review.<br>

<br>
Another item I noticed is that the only place (excluding some test code) that does not use &quot;Naming.getInitialContext()&quot; is the &quot;org.jboss.seam.remoting.messaging.JBossConnectionProvider&quot;. &nbsp;It using the &quot;new InitialContext()&quot; directly. &nbsp;Shane - is there a reason for this? <br>

</blockquote></div></div>
That class is gone now, I removed it recently.<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">
<br>
I&#39;ll write up my findings on the lookup usage asap.<br>
<br>
Thanks,<br>
Jay<br>
-- <br>
blog: <a href="http://in.relation.to/Bloggers/Jay" target="_blank">http://in.relation.to/Bloggers/Jay</a><br></div>
------------------------------------------------------------------------<div class="Ih2E3d"><br>
<br>
_______________________________________________<br>
seam-dev mailing list<br>
<a href="mailto:seam-dev@lists.jboss.org" target="_blank">seam-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/seam-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/seam-dev</a><br>
</div></blockquote>
<br>
</blockquote></div><br><br clear="all"><br>-- <br>blog: <a href="http://in.relation.to/Bloggers/Jay">http://in.relation.to/Bloggers/Jay</a><br>
</div>