Consider .NET AOT for SaxonCS console executable
Added by Martin Honnen over 1 year ago
I have done some test here with .NET 7 and SaxonCS under Windows 11 x64 and compared the performance of a AOT compiled SaxonCS 12.2 XSLT command line executable (i.e. my program is simply delegating to the SaxonCS's cmd main method with Saxon.Cmd.Command.Main(args.Prepend("transform").ToArray());
) with the normal .NET one and I find that the AOT one shows me (for one particular stylesheet) an execution time of 50 to 80 ms while the .NET one shows 115 to 125 ms.
That seems quite a difference that might be worth considering when moving SaxonCS to .NET 7 (or .NET 8).
I have not investigated, however, what the various warnings during creation/publication of the AOT executable mean in terms of potentiallt reduced functionality
Replies (7)
Please register to reply
RE: Consider .NET AOT for SaxonCS console executable - Added by Martin Honnen over 1 year ago
Also tried the same now with .NET 7 under Ubuntu 22.04 WSL and there also the execution time for the AOT version with 22 to 40 ms vs 60 to 75 for the .NET version are considerable.
Consider .NET AOT for SaxonCS console executable - Added by Norm Tovey-Walsh over 1 year ago
That seems quite a difference that might be worth considering when moving SaxonCS to .NET 7 (or
.NET 8).
Interesting. Thank you, Martin. There’s always a tension between
upgrading the latest framework because it (usually) has advantages, and
continuing to support older frameworks that our customers are still
depending on.
When we (cough “I”) accidentally published the first Saxon 12 release
compiled for Java 11 instead of Java 8, customers noticed. It broke
things. Michael has an anecdote about a customer that reported upgrading
Java for their production application was a million dollar project. I
don’t doubt them.
There’s the obvious compromise of producing Saxon compiled for .NET 6
and .NET 7 and .NET 8 etc. but the number of build artifacts we
already produce is a bit staggering and adding multiple, new artifacts
isn’t without risk.
In an effort to make principled choices, we could plan to upgrade from
one .NET LTS version to the next, explicitly choosing not to upgrade to
the interrim releases. That would suggest we would move from .NET 6 to
.NET 8 perhaps “in the summer” of 2024.
Be seeing you,
norm
--
Norm Tovey-Walsh
Saxonica
RE: Consider .NET AOT for SaxonCS console executable - Added by Martin Honnen about 1 year ago
This week Microsoft has published .NET 8 RC 1 (release candidate 1), so I did some tests with SaxonCS 12.3 and AOT and .NET 8, measuring the performance with Powershells Measure-Command
for SaxonCS as released, my attempt to AOT compile SaxonCS with .NET 8 for XSLT and win-x64 and for comparison SaxonC 12.3 EE:
Measure-Command { & 'C:\Program Files\Saxonica\SaxonCS-12.3\SaxonCS.exe' transform -it -xsl:.\processorTestHTML5Xslt3InitialTempl.xsl }
..
TotalSeconds : 1.3048388
TotalMilliseconds : 1304.8388
Measure-Command { ..\SaxonCSAOT\win-x64-net8rc1\SaxonCS12Net8RC1AotXsltTest.exe -it -xsl:.\processorTestHTML5Xslt3InitialTempl.xsl }
..
TotalSeconds : 0.3782785
TotalMilliseconds : 378.2785
Measure-Command { & 'C:\Program Files\Saxonica\libsaxon-EEC-windows-amd64-v12.3\command\Transform.exe' -it -xsl:.\processorTestHTML5Xslt3InitialTempl.xsl }
..
TotalSeconds : 0.0504808
TotalMilliseconds : 50.4808
Will be interesting to see in November when .NET 8 is officially released whether AOT compilation helps console applications or web apis doing XSLT or XQuery or schema validation with SaxonCS to improve the runtime performance.
RE: Consider .NET AOT for SaxonCS console executable - Added by Michael Kay about 1 year ago
Indeed, it looks promising.
I would suspect that these improvements come primarily from reduced start-up time; it would be interesting to see how a longer-running transformation is affected.
RE: Consider .NET AOT for SaxonCS console executable - Added by Martin Honnen about 1 year ago
Right, good point, for SaxonCS vs SaxonC and some Docbook processing the AOT of SaxonC clearly wins over the released SaxonCS
& Measure-Command { & 'C:\Program Files\Saxonica\libsaxon-EEC-windows-amd64-v12.3\command\Transform.exe' -s:.\Downloads\sections-numbered-from.xml -xsl:.\OneDrive\Documents\Docbook\docbook-xslTNG-2.1.9\xslt\docbook.xsl -o:.\Downloads\sections-numbered-from.saxoncee.html }
..
TotalSeconds : 0.3956194
TotalMilliseconds : 395.6194
PS C:\Users\marti> & Measure-Command { & 'C:\Program Files\Saxonica\SaxonCS-12.3\SaxonCS.exe' transform -s:.\Downloads\sections-numbered-from.xml -xsl:.\OneDrive\Documents\Docbook\docbook-xslTNG-2.1.9\xslt\docbook.xsl -o:.\Downloads\sections-numbered-from.saxoncs.html }
..
TotalSeconds : 2.3061467
TotalMilliseconds : 2306.1467
but it seems my AOT compiled SaxonCS .NET 8 just fails to produce an output without telling me why, perhaps the warnings during generation of the exe about XML resolver just means that stylesheet include/import doesn't work out of the box. I will need to run some simpler experiments first to see whether it is really xsl:include/import
causing the failure, not sure so far how to fix it as AOT compilation is kind of a black box experiment to me.
RE: Consider .NET AOT for SaxonCS console executable - Added by Martin Honnen about 1 year ago
A simple stylesheet with xsl:import
runs fine through the .NET 8 AOT compiled console app.
Not sure why Docbook fails, see https://saxonica.plan.io/boards/3/topics/9538 where I at least get some error message.
RE: Consider .NET AOT for SaxonCS console executable - Added by Martin Honnen almost 1 year ago
.NET 8 is now around, I guess to perhaps try to update the SaxonCS console app to exploit AOT, the article https://devblogs.microsoft.com/dotnet/creating-aot-compatible-libraries/ can help.
Please register to reply