RE: [xsl] how to estimate speed of a transformation

Subject: RE: [xsl] how to estimate speed of a transformation
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 12 Dec 2003 11:15:41 -0000
> >   one should have the right to expect that for each n the 
> computation is performed
> >   once, and if a template is called with the same value of 
> 'n' repeatedly, it does not
> >   spend time on computing doctitle again.
> > 
> > The system doesn't have to re-calculate; it could cache the 
> values so 
> > if it sees the same n again, simply re-use it.
> > 
> That's clear and obvious. What kinds of expressions and when 
> are 'cached' in each of the available processors?

Saxon does no caching of results, with the exception that there is a
"performance hint" on xsl:function that allows the results of the
function to be memoized. I have no idea whether doing any automatic
caching of values would give any notable benefits.

What Saxon does do is to try to promote subexpressions out of a loop
(giving the same effect as if you had declared a variable outside the
loop explicitly). However, at present it does most of its optimizations
within the scope of a single XPath expression, it doesn't do much of
this kind of optimization at the XSLT level. 

Saxon also does some very limited detection of common subexpressions,
for example

/a/b/c | /a/b/d

is rewritten as

/a/b/*[self::c or self::d] 
> Since such 'caching' changes computation complexity, what 
> features should expressions possess to be safely used in this way? 
You've asked this question about 100 times, and you're not going to get
an answer, because there isn't one. There is no way of predicting
performance, or even computational complexity, without knowledge of the
implementation you are using.

I think there are optimizations that it is reasonable to expect, for
example that the cost of following-sibling::a[1] is independent of how
many following siblings there are, and you should avoid using a
processor if it doesn't provide these optimizations. But there are other
optimizations that some processors will provide and others won't, that's
a fact of life.

Michael Kay

Michael Kay

 XSL-List info and archive:

Current Thread