Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-2183

XSLT result type is extremely slow for actions that produce a large xml document

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.6, 2.0.7, 2.0.8, 2.0.9, 2.0.10
    • 2.0.11, 2.1.0
    • Plugin - Tags
    • None
    • Operating system: Linux, Windows XP

    • Patch, Important

    Description

      XSL transformations take what seems like an exponential increase in time with respect to the size of the xml document produced from the action. I ran our app through a profiler and determined almost all of the time was being spent in a couple of log statements in the following method from the class, org.apache.struts2.views.xslt.AbstractAdapterNode.

      public Node getChildBeforeOrAfter(Node child, boolean before)

      { log.debug("getChildBeforeOrAfter: "); List adapters = getChildAdapters(); log.debug("childAdapters = " + adapters); log.debug("child = " + child); int index = adapters.indexOf(child); if (index < 0) throw new StrutsException(child + " is no child of " + this); int siblingIndex = before ? index - 1 : index + 1; return ((0 < siblingIndex) && (siblingIndex < adapters.size())) ? ((Node) adapters.get(siblingIndex)) : null; }

      This method gets called very frequently while the transformer is traversing the document, multiple times for each node. Since there is not a guard around the debug statements, the toString method on the adapters and child variables is called even when not in debug mode. I added the guard if (log.isDebugEnabled()) around the two lines and the transformation only took about 4 seconds instead of 80+ seconds for our action which returned about 1000 users.

      I created a patch and will attach it to this ticket. This is the first time that I have created a patch using subversion so let me know if I am missing something. It would be nice if this could be back ported to 2.0.X since we are using that branch for the time being.

      Attachments

        1. patch.txt
          1 kB
          John Krueger

        Activity

          People

            jholmes James Holmes
            johndkrueger John Krueger
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: