[jbossseam-issues] [JBoss JIRA] Closed: (JBSEAM-3485) Optimize how the InitialContext is created in org.jboss.seam.util.Naming
Shane Bryzak (JIRA)
jira-events at lists.jboss.org
Tue Nov 11 22:07:36 EST 2008
[ https://jira.jboss.org/jira/browse/JBSEAM-3485?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Shane Bryzak closed JBSEAM-3485.
I've gone with the guns-blazing option of simply caching the InitialContext the first time it is accessed. From my understanding, once it is initialized with a set of properties then these properties won't change (and these are the only important state kept within the InitialContext), meaning that there is no point in creating a new InitialContext each time if the properties are the same.
My initial testing for this looks good, in fact our example apps "seem" to be a little more responsive (although it could just all be in my head). It would be extremely interesting to get some profiling done on this before and after the change - Jay you think you could do this? If not, I'll try to find the time to get it done.
> Optimize how the InitialContext is created in org.jboss.seam.util.Naming
> Key: JBSEAM-3485
> URL: https://jira.jboss.org/jira/browse/JBSEAM-3485
> Project: Seam
> Issue Type: Task
> Components: Core
> Affects Versions: 2.1.0.BETA1
> Reporter: Jay Balunas
> Assignee: Shane Bryzak
> Fix For: 2.1.1.CR1
> Attachments: patch.txt
> Seam currently only creates and manages the InitialContext in the "org.jboss.seam.util.Naming" class (see: http://fisheye.jboss.org/browse/Seam/trunk/src/main/org/jboss/seam/util/Naming.java?r=5444 ). The properties are set in one location and done only once during the initialization of seam (see: http://fisheye.jboss.org/browse/Seam/trunk/src/main/org/jboss/seam/init/Initialization.java?r=9116#l915 ).
> I see two issues here although they are related.
> The first issue would require some caching mechanism or logic for reuse of the InitialContext instance instead of recreating it every time. WE need to determine when it makes sense to reuse an instance of the InitialContext, and when we need to get it fresh. 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.
> The second issue is that we do a certain amount of processing every time the context is requested, this could be optimized. Currently I see a few blocked threads on the "props.size()" call in the Naming class which is a synchronized method on the Hashtable. We need to maintain the logic that if the property list is empty we continue to call "new InitialContext()" and not pass in the properties object. This is because the first thing the InitialContext constructor does with a properties object is clone it which can be costly. This change is not as important if we find a way to cache the initial context. I have attached a patch that implements these changes.
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the seam-issues