|
XSLT and XPath Optimization
May 13, 2004 4:38 PM
ยท Filed under #XSLT
Here is interesting paper "XSLT and XPath Optimization" by Michael Kay. That's materials of Michael's talk at recent XML Europe conference. In this paper Michael reveals details of the XSLT and XPath optimizations performed internally by SAXON (XSLT and XQuery processor): This paper describes the main techniques used by the Saxon XSLT and XQuery processor (http://saxon.sf.net/) to optimize the execution of XSLT stylesheets and XPath expressions, and reviews some additional XSLT and XPath optimization techniques that are not (yet) used in Saxon.A must reading for those developing or thinking to develop XPath/XQuery/XSLT plumbing. [Via XML.com] Interesting quotes: Parsing of XQuery is considerably more complex than XPath parsing, because of the need to switch between the different grammatical styles used in the query prolog, in conventional expressions, and in the XML-like element constructors. XSLT parsing, of course, is trivial, because the difficult part is done by an XML parser. Most of the important static optimizations are done during the second phase, analyze(). These fall into a number of categories: Firstly, there's a range of techniques that come under the heading of parallelism. Xalan, for example, has the parser and tree builder for the source document running in parallel with the transformation engine: if the stylesheet needs access to nodes that aren't there yet, the transformation engine waits until the parser has delivered them. The real saving here would come if it was also possible to discard parts of the tree once the stylesheet has finished with them. Unfortunately no-one seems close to solving this problem, even though many stylesheets do process the source document in a broadly sequential way.etc... Comments
Well, unfortunately I share the same thoughts. The only workaround I can imagine is avoiding numerous templates for doing substitutions. I'd try xsl:key loopup instead of template matching may be. Posted by: Oleg Tkachenko at August 15, 2004 12:50 PMIt is too little said in the Internet about how different XSLT processors do match templates. As I deal with large XSLT transformations it was easy to note that .NET XSLT does loop over all templates in priority order to find appropriate template and MSXML does some optimizations to index similiar match with similiar structure (the same attribute checked for different values) or just match for element name. I tis very disappointing that adding 100 templates with match to a stylesheet with 100 templates slows it down twice. The same changes the performance of stylesheet in MSXML just by 1%. The only thing that help is spreading templates into different modes where it is possible, but sometimes it is necessary to run identity transformation handling more than 100 substitutions. Is there anything else that can be done to improve matching performance? Meanwhile, performance degradation is uch more noticable on stylesheet size growing rather than on source XPathDocument growing. Posted by: Yuriy at August 14, 2004 3:53 PMPost a comment
|
Subscribe to me
|