Bug #6565
closedPerformance Regression in DocumentFn with Java 12 or higher
0%
Description
Hello,
I have come across a slow-down that is happening when accessing files using fn:document
or checking for their existence using fn:doc-available
.
I have also attached a screenshot of the hotspot (taken from JProfiler). The bottom line seems to be that with current Java versions File.getCanonicalPath
is much slower, due to a cache that was removed from JDK.
Here are some links related to the change: https://bugs.openjdk.org/browse/JDK-8207005 https://bugs.java.com/bugdatabase/view_bug?bug_id=8309215
The was first disabled with Java 12, and then completely removed with Java 21.
From the looks of it, DocumentFn
is only using it to conveniently normalize the filename. perhaps there is a way to do that without the need to call getCanonicalPath()
.
Thanks in advance and kind regards, Philipp
Files
Updated by Philipp Nanz about 1 month ago
When using the Java system property "-Dsun.io.useCanonCaches=true" on Java 17, the hotspot is also solved.
Updated by Philipp Nanz about 1 month ago
- File SaxonDocumentKeyFix.java SaxonDocumentKeyFix.java added
We have looked into this in more detail and have come up with a solution by modifying the code at runtime using bytecode manipulation. I attach our solution, we have profiled it and it solves the problem. Note: The used solution uses Java NIO API, which is only available in Java 7 and higher.
Hope this helps!
Updated by Michael Kay about 1 month ago
Many thanks for this!
Could you please confirm that you understand the terms and conditions for the site in particular the paragraph:
When you post code fragments on this site, then unless clearly specified otherwise, you implicitly give Saxonica Ltd license to use these code fragments in its test suite; and if the code fragments represent suggested changes to the code of a Saxonica product, to use the code fragments in future versions of the product.
Updated by Philipp Nanz about 1 month ago
Yes, I can confirm that. In fact, I would be more than happy if this change makes it back into Saxon :-)
Thanks and kind regards, Philipp
Updated by Michael Kay 15 days ago
- Category set to Performance
- Status changed from New to Resolved
- Assignee set to Michael Kay
- Applies to branch trunk added
- Fix Committed on Branch 12, trunk added
- Platforms Java added
Needed to do a bit of extra tweaking to make the new code transpile to C#.
Please register to edit this issue