I'm afraid this isn't a surprise. It's a while since I looked at this area: I did manage to get the loading of compiled stylesheets down to about half the original compilation time by looking very carefully at the output of the object serialization, but it's almost certainly degraded since as a result of extra functionality and optimization, which increases the size and complexity of the expression tree that's being serializer. The existing stylesheet compilation offers no performance benefits, and I'm retaining it only because there are a handful of users who find it a good way of distributing tamper-proof code. I'm working on generating Java code as a replacement for the feature.
I find the other part of your suggestion, that compiled stylesheet run slower, difficult to believe. It's probably an effect of Java warm-up time - which, incidentally is probably as much a challenge in your environment as stylesheet compilation time.
I think a better solution to your problem would be to set up some kind of server in which Saxon is running - perhaps a web service - that accepts requests from your Perl application, and that can retain resources (like the Java VM and the stylesheet cache) between requests.
Michael Kay

From: saxon-help-bounces@lists.sourceforge.net [mailto:saxon-help-bounces@lists.sourceforge.net] On Behalf Of Derose, Steve (NIH/NLM/NCBI) [C]
Sent: 05 February 2007 22:41
To: saxon-help@lists.sourceforge.net
Subject: [saxon] Compiled ss w/ Saxon8

My colleague here has been trying out launching Saxon 8 with compiled stylesheets.
Our basic problem is that we need to run many documents through the same stylesheet, and would like to not reload it every time. Since we're controlling the process from Perl, as far as we can tell we have to launch Saxon for each document -- so we thought we could save some time by pre-compiling.
What he has found, though, is something like these times:
200 line xslt
2MB xml document
run from non-compiled ss: 5.2s
run from compiled ss: 6.2s
Should it be slower to read and use compiled stylesheets, than plain original text ones?
I understand there's overhead for deserializing; but is it really more than the cost to parse from scratch?
Or might there be something obvious we're missing? Any particular construct that might be very costly to reload?
He also noticed that the time difference didn't seem constant across xml document sizes: smaller documents would
have a smaller time difference, suggesting that compiled stylesheets actually *run* slower rather than just load slower.
Not knowing the guts of the implementation, I would have predicted that once loaded they'd run almost exactly the same
as if they hadn't been pre-compiled.
Thanks for any light you can shed.
Steve DeRose (contractor) deroses@mail.nih.gov
PubMedCentral, National Center for Biotechnology Information
National Library of Medicine, NIH