Performance analysis & recursive xslt
Added by Anonymous about 18 years ago
Legacy ID: #3966607 Legacy Poster: David Pirkle (dpirkle)
Hi, I have an xslt that is running slowly, and so I'd like to do some performance analysis on it. When I try running with the -TP command line option, I get the expected output for a while, but then I get the following error message: Error at xsl:call-template on line 104 of file:/C:/Perforce/Reporting/View/Resources/move_col.xsl: Too many nested template or function calls. The stylesheet may be looping. Transformation failed: Run-time errors were reported If I run the xslt without the -TP option, it works fine. Also, if I run with -TP but process a shorter XML file, I don't get any errors. Is there a known problem with performance analysis of an xslt that uses recursion? I'm using version 8.8, with a change to Configuration.java to fix bug 1557512 (-T doesn't enable full tracing). I can send the source xslt and sample xml if needed. David Pirkle Symyx Technologies, Inc.
Replies (3)
Please register to reply
RE: Performance analysis & recursive xslt - Added by Anonymous about 18 years ago
Legacy ID: #3966620 Legacy Poster: Michael Kay (mhkay)
Because the TraceListener interface in Saxon was designed primarily for stylesheet debugging rather than performance monitoring, it disables certain rewrite optimizations that make the flow-of-execution difficult to follow. One of these is tail-call optimization, and it's almost certainly this that is hitting you. Tail-call optimization turns a recursive call into a loop to conserve stack space, and without it you run out of stack after about 500 to 1000 recursive calls. You can sometimes solve this problem by running with a smaller source document. If that doesn't work in your case, I'm afraid I don't have any other good ideas.
RE: Performance analysis & recursive xslt - Added by Anonymous about 18 years ago
Legacy ID: #3966642 Legacy Poster: David Pirkle (dpirkle)
Thanks, I suspected as much. I'll use a smaller source document. One more question: if the tail-call optimization is disabled, does that significantly slow down recursive code? I'm wondering how much I can trust the profile of recursive templates and functions if the profiling is disabling an optimization that is normally enabled.
RE: Performance analysis & recursive xslt - Added by Anonymous about 18 years ago
Legacy ID: #3967013 Legacy Poster: Michael Kay (mhkay)
Tail-call optimization is done essentially to conserve stack space, not to speed up execution, so I don't think this should make your profiling unreliable. There are a few other things done differently when tracing is enabled, for example global variables are evaluated eagerly at the start of the run. Generally this should make the profile data easier to understand, because the effect of many optimizations is to move costs from the place where the code is written to somewhere else. But you're right that it's not an exact science.
Please register to reply