Bug #5686
closedHeap size problems, and crash in TraceListener
100%
Description
Problem reported by email.
To be exact, I have two issues tightly related to each other. First of all I have a transformation (step) where for some element nodes an attribute "variant" must be produced with the help of a function (See test-set at "lib/EDK/Scripts/XSL/PublishingCore/mod.filter.xsl", line 123.).
(1) One problem is that the underlying stack of the function called (exf:get-variant#1) seems to have a bottleneck somewhere as the heap space consumption seems to grow exponentially with the input data size. When the heap space is getting to its limits, the Java garbage collector is taking a lot of CPU time so that the transformation cannot really finish with my configuration.
The XSLT code is lacking maintenance here and there, but it's not clear what the main reason for the symptom described above exactly is. So the question is if you could give me a hint where this bottleneck may be located in the scripts? It's not the first time I have such an issue but here I have no idea how to isolate the problem.
I already tested with Saxon PE 9.9, 10.8, and 11.4; Saxon PE 9.9 is currently used in production by our clients.
(2) The second issue is that I tried out the TimingTraceListener via commandline option "-T:net.sf.saxon.trace.TimingTraceListener" and also "-TP:profile.html" without success. I always get a "NullPointerException" like this one:
java.lang.NullPointerException: Cannot invoke "net.sf.saxon.expr.Expression.process(net.sf.saxon.event.Outputter, net.sf.saxon.expr.XPathContext)" because "this.body" is null
at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:394)
at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:551)
at net.sf.saxon.trans.rules.TextOnlyCopyRuleSet.process(TextOnlyCopyRuleSet.java:72)
at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:524)
at net.sf.saxon.trans.XsltController.applyTemplates(XsltController.java:685)
at net.sf.saxon.event.TransformerReceiver.close(TransformerReceiver.java:124)
at net.sf.saxon.event.RegularSequenceChecker.close(RegularSequenceChecker.java:199)
at net.sf.saxon.event.ComplexContentOutputter.close(ComplexContentOutputter.java:736)
at net.sf.saxon.event.PushToReceiver$DocImpl.sendEndEvent(PushToReceiver.java:219)
at net.sf.saxon.event.PushToReceiver$ContainerImpl.close(PushToReceiver.java:135)
at net.sf.saxon.trace.TimingTraceListener.close(TimingTraceListener.java:150)
at net.sf.saxon.trans.XsltController.callTemplate(XsltController.java:886)
at net.sf.saxon.s9api.Xslt30Transformer.callTemplate(Xslt30Transformer.java:485)
at net.sf.saxon.Transform.processFile(Transform.java:1382)
at net.sf.saxon.Transform.doTransform(Transform.java:871)
at net.sf.saxon.Transform.main(Transform.java:81)
java.lang.RuntimeException: Internal error evaluating template rule at line 79 in module file:///C:/_/issues/2022-09-08-avm-hadria-iirds-performance/saxonica/profile.xsl
at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:411)
at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:551)
at net.sf.saxon.trans.rules.TextOnlyCopyRuleSet.process(TextOnlyCopyRuleSet.java:72)
at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:524)
at net.sf.saxon.trans.XsltController.applyTemplates(XsltController.java:685)
at net.sf.saxon.event.TransformerReceiver.close(TransformerReceiver.java:124)
at net.sf.saxon.event.RegularSequenceChecker.close(RegularSequenceChecker.java:199)
at net.sf.saxon.event.ComplexContentOutputter.close(ComplexContentOutputter.java:736)
at net.sf.saxon.event.PushToReceiver$DocImpl.sendEndEvent(PushToReceiver.java:219)
at net.sf.saxon.event.PushToReceiver$ContainerImpl.close(PushToReceiver.java:135)
at net.sf.saxon.trace.TimingTraceListener.close(TimingTraceListener.java:150)
at net.sf.saxon.trans.XsltController.callTemplate(XsltController.java:886)
at net.sf.saxon.s9api.Xslt30Transformer.callTemplate(Xslt30Transformer.java:485)
at net.sf.saxon.Transform.processFile(Transform.java:1382)
at net.sf.saxon.Transform.doTransform(Transform.java:871)
at net.sf.saxon.Transform.main(Transform.java:81)
Caused by: java.lang.NullPointerException: Cannot invoke "net.sf.saxon.expr.Expression.process(net.sf.saxon.event.Outputter, net.sf.saxon.expr.XPathContext)" because "this.body" is null
at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:394)
... 15 more
Fatal error during transformation: java.lang.RuntimeException: Internal error evaluating template rule at line 79 in module file:///C:/_/issues/2022-09-08-avm-hadria-iirds-performance/saxonica/profile.xsl
The exception also is reproducible with Saxon 9.9, 10.8, and 11.4.
(3) I put together a test-set with a powershell script "transform.ps1" that can simply be executed with ".\transform.ps1". If you are on Unix or Linux you should be easily be able to read the script (maybe it runs on Powershell Core) and adapt for bash/sh.
Please treat the test-set as confidential.
Preqrequisites: Adapt "$Global:JavaHome" and "$Global:SaxonClassPath" Change "$xmlIn" to transform a minimized or a complete test file (see following)
Input data: "data/Export.debug/P_01_de-DE/Work/in.xml" Complete input file that is suitable for reproducing the bottleneck issue (I realized the heap space thing when setting Java max heap to 10G) "data/Export.debug/P_01_de-DE/Work/in.min.xml" Reduced input file that is suitable for reproducing the profiling error
Please register to edit this issue