ICEfaces
  1. ICEfaces
  2. ICE-4088

optimize xerces DOM operations

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.8RC1
    • Fix Version/s: 1.8RC2, 1.8
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      ICEfaces

      Description


      By default, xerces runs with errorChecking set to true:

      (times in nanoseconds, 500 iterations)

      errorChecking(true) ice: auctionMonitor

      lifecycle took 9709000 RENDER: 8293000
      lifecycle took 9981000 RENDER: 8481000
      lifecycle took 9542000 RENDER: 8085000
      lifecycle took 9827000 RENDER: 8356000
      lifecycle took 9794000 RENDER: 8374000
      lifecycle took 10348000 RENDER: 8960000
      lifecycle took 9782000 RENDER: 8310000
      lifecycle took 10174000 RENDER: 8751000
      lifecycle took 10328000 RENDER: 8603000
      lifecycle took 9965000 RENDER: 8443000


      errorChecking(false) ice: auctionMonitor:

      lifecycle took 9419000 RENDER: 7985000
      lifecycle took 9375000 RENDER: 7998000
      lifecycle took 12394000 RENDER: 10994000
      lifecycle took 9798000 RENDER: 8356000
      lifecycle took 9367000 RENDER: 7978000
      lifecycle took 9363000 RENDER: 7843000
      lifecycle took 9409000 RENDER: 8021000
      lifecycle took 9292000 RENDER: 7936000
      lifecycle took 9438000 RENDER: 8047000
      lifecycle took 10291000 RENDER: 8296000

      5% improvement on the average.

      This can be enabled by the following in DOMResponseWriter:

              document = DOCUMENT_BUILDER.newDocument();
              ((com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl) document).setErrorChecking(false);

      Perhaps this should be the default, but configurable with a context parameter.

        Issue Links

          Activity

          Ted Goddard created issue -
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #18355 Tue Feb 17 10:47:53 MST 2009 ted.goddard disable DOM error checking options (ICE-4088)
          Files Changed
          Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/context/DOMResponseWriter.java
          Hide
          Ted Goddard added a comment -

          After 6000 invocations of the test, the performance difference reduced to 7.76ms for the optimization vs 7.86ms without.

          Show
          Ted Goddard added a comment - After 6000 invocations of the test, the performance difference reduced to 7.76ms for the optimization vs 7.86ms without.
          Ted Goddard made changes -
          Field Original Value New Value
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 1.8 [ 10161 ]
          Resolution Fixed [ 1 ]
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #18422 Tue Feb 24 16:00:00 MST 2009 ted.goddard disable DOM error checking by default for popup menu (ICE-4088)
          Files Changed
          Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/context/DOMResponseWriter.java
          Ken Fyten made changes -
          Link This issue blocks ICE-4131 [ ICE-4131 ]
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #18559 Fri Mar 13 10:26:10 MDT 2009 ted.goddard remove DOMContext.attach and disable DOM error checking (ICE-4088)
          Files Changed
          Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/context/DOMResponseWriter.java
          Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/context/DOMContext.java
          Ken Fyten made changes -
          Fix Version/s 1.8RC2 [ 10163 ]
          Fix Version/s 1.8 [ 10161 ]
          Hide
          Eric Bernstein added a comment -

          This solution checked in will cause a problem if you're using an JRE other than SUN's and com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl is not in the classpath. The instanceof check does require the class to be on the classpath at runtime. (I got hit with this while trying to deploy the trunk of IceFaces to an IBM JRE on AIX.

                   document = DOCUMENT_BUILDER.newDocument();
                   if (!isDOMChecking) {
                       if (document instanceof com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl) {
                           ((com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl) document).setErrorChecking(false);
                       }
                   }
          

          I'm afraid I don't have an elegant solution for this, but the below should work as non-optimal as it is

          	    Class klass = null;
          	    try {
                          //really just need to this once in a static block or at initialization
          	        klass = Class.forName("com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl");
          	    }
          	    catch (ClassNotFoundException e) {
          	        //suppress
          	    }
          	    
          	    if (klass != null && klass.isAssignableFrom(document.getClass())) {
          	        ((com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl) document).setErrorChecking(false);
                  }
          
          Show
          Eric Bernstein added a comment - This solution checked in will cause a problem if you're using an JRE other than SUN's and com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl is not in the classpath. The instanceof check does require the class to be on the classpath at runtime. (I got hit with this while trying to deploy the trunk of IceFaces to an IBM JRE on AIX. document = DOCUMENT_BUILDER.newDocument(); if (!isDOMChecking) { if (document instanceof com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl) { ((com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl) document).setErrorChecking( false ); } } I'm afraid I don't have an elegant solution for this, but the below should work as non-optimal as it is Class klass = null ; try { //really just need to this once in a static block or at initialization klass = Class .forName( "com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl" ); } catch (ClassNotFoundException e) { //suppress } if (klass != null && klass.isAssignableFrom(document.getClass())) { ((com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl) document).setErrorChecking( false ); }
          Hide
          Ted Goddard added a comment -

          Thanks for noticing this, we'll definitely use a reflection strategy for obtaining the xerces internal API. Does the corresponding API exist (perhaps in a different package) on the AIX JRE?

          Show
          Ted Goddard added a comment - Thanks for noticing this, we'll definitely use a reflection strategy for obtaining the xerces internal API. Does the corresponding API exist (perhaps in a different package) on the AIX JRE?
          Ted Goddard made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Assignee Ted Goddard [ ted.goddard ]
          Hide
          Eric Bernstein added a comment -

          It would appear the IBM's JRE (my current deployment) is using a pure xerces implementation, so the default document class is
          org.apache.xerces.dom.DocumentImpl
          which does inherit
          org.apache.xerces.dom.CoreDocumentImpl
          which also has the setErrorChecking method on it

          I don't have access to BEA's JRE, but adding the optimization for pure xerces would probably cover a few bases.

          Show
          Eric Bernstein added a comment - It would appear the IBM's JRE (my current deployment) is using a pure xerces implementation, so the default document class is org.apache.xerces.dom.DocumentImpl which does inherit org.apache.xerces.dom.CoreDocumentImpl which also has the setErrorChecking method on it I don't have access to BEA's JRE, but adding the optimization for pure xerces would probably cover a few bases.
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #18601 Wed Mar 18 12:03:16 MDT 2009 ted.goddard use reflection for AIX support (ICE-4088)
          Files Changed
          Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/context/DOMResponseWriter.java
          Hide
          Ted Goddard added a comment -

          The checked in fix now simply looks for the setErrorChecking method, so it should invoke the method whether the class is xerces or a com.sun implementation.

          Show
          Ted Goddard added a comment - The checked in fix now simply looks for the setErrorChecking method, so it should invoke the method whether the class is xerces or a com.sun implementation.
          Ted Goddard made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Hide
          Ted Goddard added a comment -

          This optimization is not the default; to enable it:

          DOMResponseWriter.setDOMErrorChecking(false);

          Show
          Ted Goddard added a comment - This optimization is not the default; to enable it: DOMResponseWriter.setDOMErrorChecking(false);
          Ken Fyten made changes -
          Fix Version/s 1.8 [ 10161 ]
          Ken Fyten made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Assignee Ted Goddard [ ted.goddard ]

            People

            • Assignee:
              Unassigned
              Reporter:
              Ted Goddard
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: