You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Jeffrey Rodriguez <je...@hotmail.com> on 2000/12/01 01:01:56 UTC
Re: Optimizing Xerces
Hi Elena,
I will review your patches and will apply them to Xerces, great job.
Thanks,
Jeffrey Rodriguez
XML Development
IBM Cupertino
>From: Elena Litani <hl...@jtcsv.com>
>Reply-To: xerces-j-dev@xml.apache.org
>To: xerces-j-dev@xml.apache.org
>Subject: Optimizing Xerces
>Date: Thu, 30 Nov 2000 18:17:15 -0500
>
>Hi,
>This patch addresses the problem reported in email "Rampant object
>creation under Xerces J" from Andy Wai.
>
>In general, Xerces-J was creating way too many objects, when the
>validation is turned off. For example, if user creates a parser and when
>in loop call parse() of the same small XML document (which does not even
>has <!DOCTYPE> line):
>In xerces-j 1.2.1 we would create ~132,000 objects.
>After the fix, we would create only 44,000 objects for the described
>above case.
>
>
>Can somebody look at this fix and possibly apply it?
>
>Thank you,
>Elena
>Index: GrammarResolverImpl.java
>===================================================================
>RCS file:
>/home/cvspublic/xml-xerces/java/src/org/apache/xerces/validators/common/GrammarResolverImpl.java,v
>retrieving revision 1.3
>diff -u -r1.3 GrammarResolverImpl.java
>--- GrammarResolverImpl.java 2000/11/04 00:13:15 1.3
>+++ GrammarResolverImpl.java 2000/11/30 20:33:53
>@@ -86,8 +86,11 @@
> */
> private Hashtable fGrammarRegistry = new Hashtable();//This class
>keeps a hashtable of references to Grammar structures
>
>- private DatatypeValidatorFactoryImpl fDataTypeReg = new
>DatatypeValidatorFactoryImpl();
>+ //optimization -EL
>+ //private DatatypeValidatorFactoryImpl fDataTypeReg = new
>DatatypeValidatorFactoryImpl();
>+ private DatatypeValidatorFactoryImpl fDataTypeReg = null;
>
>+
> //
> // Constructors
> //
>@@ -112,6 +115,9 @@
> }
>
> public DatatypeValidatorFactory getDatatypeRegistry(){
>+ if (fDataTypeReg == null) { //optimization -EL
>+ fDataTypeReg = new DatatypeValidatorFactoryImpl();
>+ }
> return fDataTypeReg;
> }
>
>@@ -202,7 +208,10 @@
> */
> public void clearGrammarResolver() {
> fGrammarRegistry.clear();
>- fDataTypeReg.resetRegistry();
>+ if (fDataTypeReg != null ) { //optimization -EL
>+ fDataTypeReg.resetRegistry();
>+ }
>+
> }
>
>
>Index: XMLValidator.java
>===================================================================
>RCS file:
>/home/cvspublic/xml-xerces/java/src/org/apache/xerces/validators/common/XMLValidator.java,v
>retrieving revision 1.96
>diff -u -r1.96 XMLValidator.java
>--- XMLValidator.java 2000/11/18 01:32:30 1.96
>+++ XMLValidator.java 2000/11/30 23:05:26
>@@ -405,7 +405,10 @@
>
> public void setGrammarResolver(GrammarResolver grammarResolver){
> fGrammarResolver = grammarResolver;
>- initDataTypeValidators();
>+ if (fValidating) { //optimization -EL
>+ initDataTypeValidators();
>+ }
>+
> }
>
> //
>@@ -464,6 +467,11 @@
> fDynamicDisabledByValidation = true;
> }
> fValidating = fValidationEnabled;
>+
>+ //optimization: don't create unnecessary DatatypeValidators. - EL
>+ if (fValidating) {
>+ initDataTypeValidators();
>+ }
> }
>
> /** Returns true if validation is enabled. */
>@@ -495,6 +503,12 @@
> fValidationEnabledByDynamic = true;
> }
> fValidating = fValidationEnabled;
>+
>+ //optimization: don't create unnecessary DatatypeValidators. - EL
>+ if (fValidating) {
>+ initDataTypeValidators();
>+ }
>+
> }
>
> /** Returns true if validation is dynamic. */
>@@ -1029,6 +1043,10 @@
> try {
> this.fValIDRef.validate( null, this.fValidateIDRef );
> this.fValIDRefs.validate( null, this.fValidateIDRef );
>+
>+ this.fValID.validate( null, this.fResetID );
>+ this.fValIDRef.validate(null, this.fResetIDRef );
>+ this.fValIDRefs.validate(null, this.fResetID );
> } catch ( InvalidDatatypeValueException ex ) {
> reportRecoverableXMLError( ex.getMajorCode(),
>ex.getMinorCode(),
> ex.getMessage() );
>@@ -1037,13 +1055,7 @@
> }
> }
>
>- try {//Reset datatypes state
>- this.fValID.validate( null, this.fResetID );
>- this.fValIDRef.validate(null, this.fResetIDRef );
>- this.fValIDRefs.validate(null, this.fResetID );
>- } catch ( InvalidDatatypeValueException ex ) {
>- System.err.println("Error re-Initializing: ID,IDRef,IDRefs
>pools" );
>- }
>+
> return;
> }
>
>@@ -1443,14 +1455,17 @@
>
> /** Reset pool. */
> private void poolReset() {
>+ if (fValidating) { //optimization: -EL
> try {
> //System.out.println("We reset" );
>- this.fValID.validate( null, this.fResetID );
>- this.fValIDRef.validate(null, this.fResetIDRef );
>- this.fValIDRefs.validate(null, this.fResetIDRef );
>+ this.fValID.validate( null, this.fResetID );
>+ this.fValIDRef.validate(null, this.fResetIDRef );
>+ this.fValIDRefs.validate(null, this.fResetIDRef );
>+
> } catch ( InvalidDatatypeValueException ex ) {
> System.err.println("Error re-Initializing: ID,IDRef,IDRefs
>pools" );
> }
>+ }
> } // poolReset()
>
> /** Reset common. */
>@@ -1520,8 +1535,6 @@
> fDATATYPESymbol = fStringPool.addSymbol("<<datatype>>");
> fEpsilonIndex = fStringPool.addSymbol("<<CMNODE_EPSILON>>");
> fXMLLang = fStringPool.addSymbol("xml:lang");
>-
>- initDataTypeValidators();
>
> } // init()
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
_____________________________________________________________________________________
Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com