Re: [xslt] RE: [xml] does xsltproc caches subexpressions

On Wednesday 24 May 2006 02:13, Daniel Veillard wrote:
> On Mon, May 22, 2006 at 07:17:02PM +0200, Buchcik, Kasimier wrote:
> > > What kind of optimizations does libxml2 do on predicated, in general?
>   basically nearly nothing except [1] and [last()] optimizations
> [..]
> > The following might be a bit vague, since I only scratched Libxml2's
> > XPath
> > code.
> > I think Libxml2 does only the "early exit" optimization; at least I
> > haven't
> > found code indicating the opposite. Although in the case of [n], it
> > doesn't
> > evaluate "n", but just triggers execution of optimized evaluation
> > functions
> > wrt the position. The 3 functions are:
> > 1) xmlXPathCompOpEvalFirst()       - used for "[1]"
> > 2) xmlXPathCompOpEvalLast()        - used for "last()"
> > 3) xmlXPathNodeCollectAndTestNth() - used for "[n]"
> >
> > But there's one catch for the "early exit": In Libxml2 each predicate is
> > evaluated on the node-set result of its preceding predicate; so the
> > "early exit" is only possible at the last level of predicates.
>   yes, that's my recollection too.
> Basically my design rules were KISS and try to optimize only when hitting
> something obviously slowing things down. There is a number ofpotential
> optimization option which could be done on the expression compiled tree
> either at compilation time, or in context, but I never really spent much
> time on those. Bug in those areas can also be extremely hard to catch :-)

No doubt! It's almost entertaining how crazy bugs one can encounter when doing 
AST rewrites. What triggers a bug in an AST-rewriting implementation can be 
completely impossible to even imagine and appear very irrational. The only 
way to survive, is to be completely testing-oriented; if there's something 
which isn't tested it is bound to break.

In my own implementation mentioned in my other mail I've written a small 
framework for doing rewrites. For example, there's an optimization which 
rewrites "count(expr) > 0)" into "fn:exists(expr)"(meaning the expression 
exits after the first item from evaluating 'expr', instead of all of them).

More "advanced" compiler developments has become more fun with the "second 
generation" technologies because they are statically typed. For XPath 
2.0/XQuery there exists the XQTS test suite, which will contain about 14000 
tests, which is very helpful for this kind of work.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]