Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Massive Performance Problem: JAXB Creates hundreds of TransformerFactories #1824

Open
mkarg opened this issue Nov 26, 2024 · 1 comment
Open

Comments

@mkarg
Copy link
Member

mkarg commented Nov 26, 2024

As documented in https://saxonica.plan.io/boards/3/topics/9475?r=9566 we came across a massive performance problem when using Saxon XSLT engine. Saxon is optimized for reuse, so creation of a TransformerFactory is very slow (10 times slower as default engine bundled with OpenJDK), but the actual marshalling and unmarshalling is super fast. Unfortunately, for non-trivial contexts, JAXB-RI creates huge amounts of TransformerFactories (not just Transformers). So in the end, JAXB-RI on Saxon is hundreds of times slower than on JDK.

IMHO it is a good idea that Saxon precreates things when creating a Factory (so creating Transformers is fast) and what JAXB-RI does is, let's say, "uncommon": Creating lots of Factories (instead of just Transformers).

I did a quick test-drive which proofs that JAXB-RI on Saxon is not slow once I patched JAXB-RI to re-use the same TransformerFactory instead of creating new factories. I could provide a PR, but I wonder if there is something I am missing here? Is there a good reason to create a new factory always? Will reusing Factories (not Transformers!) break something?

@mkarg
Copy link
Member Author

mkarg commented Nov 28, 2024

@lukasj Does it makes sense to set up a PR for factory caching or do you see architectural constrains that this would violate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant