Saxon with GraalVM and native/AOT compilation

Nigel Whitaker <nigel.whitaker-QbeLIGf9AXdWk0Htik3J/[email protected]> Tue, 15 Sep 2020 16:36:00 +0000
Newsgroups gmane.text.xml.saxon.help
Message-ID <[email protected]>
Hello,

I’ve been experimenting with the GraalVM and native compilation recently.  I’m on my third pass of AOT compilation trying to get things to work and am hitting a number of issues relating to Saxon.

For the record, here’s the journey so far:

Step 1:  – it didn’t like:

Processor p= new Processor(true);

I don’t have the error message to hand, but was fixed with:

Processor p= new Processor(new ProfessionalConfiguration());

Step 2 – at compile time I got:

com.oracle.svm.core.util.UserError$UserException: Class initialization of com.saxonica.functions.extfn.SendMail failed. Use the option --initialize-at-run-time=com.saxonica.functions.extfn.SendMail to explicitly request delayed initialization of this class.

Fixed in the POM:

<profiles>
    <profile>
      <id>native</id>
      <properties>
        <quarkus.native.additional-build-args>--initialize-at-run-time=com.saxonica.functions.extfn.SendMail</quarkus.native.additional-build-args>


Step 3 – then at runtime I see this in the stacktrace:

  at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
  Caused by: java.lang.IllegalStateException: Failed to load com.saxonica.xsltextn.style.SaxonElementFactory. Check that saxon9ee.jar is on the classpath
  at com.saxonica.config.ProfessionalConfiguration.declareBuiltInExtensionElementNamespaces(ProfessionalConfiguration.java:890)
  at com.saxonica.config.ProfessionalConfiguration.<init>(ProfessionalConfiguration.java:142)
  at com.deltaxml.json.rest.ComparisonService.<init>(ComparisonService.java:116)


I could plow on diagnosing/fixing, but each AOT compilation run takes about 20 minutes.  I could be doing this a while and should probably optimize things to reduce the size of the AOT compile to just saxon[hpe]e.jar
But then I wondered:  has anyone already done it or is perhaps thinking about it and wants to share the effort?

For those wondering why:  We're using Quarkus and trying to deploy a native executable to AWS lambda (it’s a JAX-RS based REST API) with the hope the native functions will have improved startup time and possibly memory footprint.

I'm not quite expecting things to be as good as the numbers here:  https://dzone.com/articles/microservices-quarkus-vs-spring-boot
But I'm also hoping it won't be as bad overall as Adam's numbers:  https://blog.adamretter.org.uk/graalvm-utf-8-validation/ particularly for startup.

Any experiences to share?

Thanks,

Nigel

-- 
Nigel Whitaker, DeltaXML Ltd, Malvern Hills Science Park, WR14 3SZ, UK.  Regisered in England 02528681

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[email protected]
https://lists.sourceforge.net/lists/listinfo/saxon-help
image001.png (image/png, 4.4 KB) - not displayed