xsl-list
[Top] [All Lists]

Re: [xsl] An observation on the performance of fn:transform

2020-07-03 03:54:03
On 03/07/2020 09:44, Norman Tovey-Walsh ndw(_at_)nwalsh(_dot_)com wrote:
Hello world,

This isn’t a complaint, or explicitly a request for advice (though I’m
always happy for helpful suggestions), just an observation. The workflow
for processing DocBook documents is roughly this pipeline:

1. Fixup the logical structure of the document (expand entities and
    replace entityref attributes with the corresponding fileref
    attributes).
2. Perform XInclude
3. Convert DocBook 4.x markup to 5.x markup if the source document
    appears to be DocBook 4.x (i.e., if its root element is in no
    namespace)
4. Perform transclusion[1]
5. Profile
6. Resolve annotations
7. Resolve XLinks (including external link bases)

....
So I coded that up. I now have an *eight* stage pipeline where the last
stage does the transformation to HTML, cleanup of that HTML, and
possible chunking. It’s all still in one stylesheet with modes because I
haven’t teased it apart yet, it’s just being run with fn:transform
instead of with a mode in the same stylesheet.

The performance difference is interesting.

Running 1,426 tests through the 8 stage pipeline: 4m19s.
Running 1,542 tests through the original 7 stages: 50s.

There are fewer tests in the former case because some of my XSpec tests
just can’t work against the new driver; I’ll have to run two sets of
tests which is kind of a drag, but I should be running separate tests
for all the stages anyway so I guess that’s just the way it is.

The performance difference is presumably because it takes ~0.15s to
compile the main stylesheet each time. Which is, you know, pretty damned
fast, but adds up if you’re going to do it thousands of times in a row.
.....
Perhaps a argument for something akin to fn:compile-transform($options as map(*)) as function($options), which does the compilation once and returns an exectuable function. Before XSLT3 and xsl:evaluate, Saxon had (and still has) something similar for XPath: saxon:expression() and saxon:evaluate()


--
*John Lumley* MA PhD CEng FIEE
john(_at_)saxonica(_dot_)com <mailto:john(_at_)saxonica(_dot_)com>
on behalf of Saxonica Ltd
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>