The xslt result type is extremely slow for actions that produce a large xml 
document.
-------------------------------------------------------------------------------------

                 Key: WW-2183
                 URL: https://issues.apache.org/struts/browse/WW-2183
             Project: Struts 2
          Issue Type: Improvement
          Components: Views
    Affects Versions: 2.0.10, 2.0.9, 2.0.8, 2.0.7, 2.0.6
         Environment: Operating system: Linux, Windows XP
            Reporter: John Krueger
         Attachments: patch.txt

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.



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to