Skip to content

Massive Performance Problem: JAXB Creates hundreds of TransformerFactories #1824

@mkarg

Description

@mkarg

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions