node.jssaxon-js

SaxonJS performance conserns


I just found and started using Saxon-JS to be able to run Schematron validations on Peppol (Peppol.eu) messages and it works great!

I've "pre-compiled" the Schemat's needed into JSON (using schxslt and xslt3) and I am then executing the SaxonJS.transform() on the data.

As these stylesheets are fairly big it takes some time and performance is of key as it is run through a API.

I run the three calls in a Promise.all() and have added timers. From the timers I can see that the function calls happens in parallel but the execution of SaxonJS.transform() seems to be sequential, i.e. when the first SaxonJS.transform() returns the next starts...

I tried adding threads to the code to get it running in "workers" but I need to send a XMLDom object to the function and threadsisn't supporting that it seems...

enter image description here

There's about 430ms in between the two executions of the runTransform() and they are called like:

let [xsdResult, valid, valid2] = await Promise.all([
  xsdValidation(event, xmlDoc),
  runTransform('EN16931-UBL-validation-preprocessed.sef.json', event, ves),
  runTransform('PEPPOL-EN16931-UBL.sef.json', event, ves)
]);

Shouldn't the functions run in parallel (at least "more" in parallel)?


Solution

  • It was another await in function runTransform() that was "blocking" and not the SaxonJS.transform() as initially thought...

    Mind those Promises... :o