admin@glassfish.java.net

Code review - performance related changes

From: Ashish Sahni <Ashish.Sahni_at_Sun.COM>
Date: Wed, 04 Oct 2006 17:40:44 -0700

Hi,
During some performance profiles, it was revealed that the cloning of
the domain.xml DOM tree during deployment was a hotspot.
Apparently, a couple of the clone calls existed simply existed because
of a bug in the earlier versions of schema2bean library.
The removal of the clone calls is reflected in ConfigBean and ConfigAddImpl
and with the change ConfigBean.clone is no longer as big a hotspot
during deployment
as before. The other change is to enable the caching so that domain.xml
is not parsed
if it has been parsed before. This change is in
AppserverClusterViewFromCacheRepository.
Let me know if you have any feedback on the changes.

Thanks
Ashish


attached mail follows:



Index: ./appserv-commons/src/java/com/sun/enterprise/config/ConfigBean.java
===================================================================
RCS file: /cvs/glassfish/appserv-commons/src/java/com/sun/enterprise/config/ConfigBean.java,v
retrieving revision 1.8
diff -c -w -r1.8 ConfigBean.java
*** ./appserv-commons/src/java/com/sun/enterprise/config/ConfigBean.java 21 Feb 2006 21:28:11 -0000 1.8
--- ./appserv-commons/src/java/com/sun/enterprise/config/ConfigBean.java 4 Oct 2006 16:16:56 -0000
***************
*** 922,928 ****
                          this.xpath,
                          ((ConfigBean)value).getAbsoluteXPath(this.xpath),
                          name,
! ((ConfigBean)this.ctx.getRootConfigBean().clone()));
                  if(cChange != null) cChange.setGlobalLastModified(this.getGlobalLastModified());
               } catch(Exception ce) {
                   ce.printStackTrace();
--- 922,931 ----
                          this.xpath,
                          ((ConfigBean)value).getAbsoluteXPath(this.xpath),
                          name,
! //this clone adds a lot of overhead and was there
! //because of a bug in schema2beans
! //((ConfigBean)this.ctx.getRootConfigBean().clone()));
! ((ConfigBean)this.ctx.getRootConfigBean()));
                  if(cChange != null) cChange.setGlobalLastModified(this.getGlobalLastModified());
               } catch(Exception ce) {
                   ce.printStackTrace();


Index: ./appserv-commons/src/java/com/sun/enterprise/config/impl/ConfigAddImpl.java
===================================================================
RCS file: /cvs/glassfish/appserv-commons/src/java/com/sun/enterprise/config/impl/ConfigAddImpl.java,v
retrieving revision 1.3
diff -c -w -r1.3 ConfigAddImpl.java
*** ./appserv-commons/src/java/com/sun/enterprise/config/impl/ConfigAddImpl.java 25 Dec 2005 04:10:41 -0000 1.3
--- ./appserv-commons/src/java/com/sun/enterprise/config/impl/ConfigAddImpl.java 4 Oct 2006 16:17:10 -0000
***************
*** 98,104 ****
      }
      
      public ConfigAddImpl(ConfigContext ctx, String xpath) throws ConfigException {
! this.cb = (ConfigBean) ctx.getRootConfigBean().clone();
          this.xpath = xpath;
          this.name = ConfigXPathHelper.getLastNodeName(xpath);
          this.parentXpath = ConfigXPathHelper.getParentXPath(xpath);
--- 98,105 ----
      }
      
      public ConfigAddImpl(ConfigContext ctx, String xpath) throws ConfigException {
! //this.cb = (ConfigBean) ctx.getRootConfigBean().clone();
! this.cb = (ConfigBean) ctx.getRootConfigBean();
          this.xpath = xpath;
          this.name = ConfigXPathHelper.getLastNodeName(xpath);
          this.parentXpath = ConfigXPathHelper.getParentXPath(xpath);


Index: ./admin-core/config-api/src/java/com/sun/enterprise/config/serverbeans/AppserverClusterViewFromCacheRepository.java
===================================================================
RCS file: /cvs/glassfish/admin-core/config-api/src/java/com/sun/enterprise/config/serverbeans/AppserverClusterViewFromCacheRepository.java,v
retrieving revision 1.6
diff -c -w -r1.6 AppserverClusterViewFromCacheRepository.java
*** ./admin-core/config-api/src/java/com/sun/enterprise/config/serverbeans/AppserverClusterViewFromCacheRepository.java 25 Dec 2005 03:47:54 -0000 1.6
--- ./admin-core/config-api/src/java/com/sun/enterprise/config/serverbeans/AppserverClusterViewFromCacheRepository.java 4 Oct 2006 16:17:24 -0000
***************
*** 49,55 ****
          }
          myName = System.getProperty(SystemPropertyConstants.SERVER_NAME);
          final String url = domainXmlUrl;
! domainCC = ConfigFactory.createConfigContext(url, true, true, false, false);
      }
  
      public ConfigContext getUnResolvedConfigContext(){
--- 49,56 ----
          }
          myName = System.getProperty(SystemPropertyConstants.SERVER_NAME);
          final String url = domainXmlUrl;
! // enable caching - with caching domain.xml gets read/parsed one less
! domainCC = ConfigFactory.createConfigContext(url, true, true, true, false);
      }
  
      public ConfigContext getUnResolvedConfigContext(){