perf: cache compiled XSLT Templates per XSL file in MessageCodeGenerator#1231
Draft
Copilot wants to merge 1 commit into
Draft
perf: cache compiled XSLT Templates per XSL file in MessageCodeGenerator#1231Copilot wants to merge 1 commit into
Copilot wants to merge 1 commit into
Conversation
Agent-Logs-Url: https://github.com/quickfix-j/quickfixj/sessions/e6405c75-ee5e-4d1b-8f7a-7970f31601fb Co-authored-by: chrjohn <6644028+chrjohn@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
chrjohn
May 19, 2026 19:52
View session
Member
|
@copilot the pr description is not correct. Please add the changes that were done in this PR. |
Contributor
Author
Updated the PR description. It now explains the actual change: caching compiled XSLT |
Copilot
AI
changed the title
No changes made — analysis only
perf: cache compiled XSLT Templates per XSL file in MessageCodeGenerator
May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cache compiled XSLT
Templatesper XSL file inMessageCodeGeneratorto avoid recompiling the same stylesheet on every generated file.Problem
MessageCodeGenerator.createTransformer()was creating a newTransformerFactoryinstance and callingnewTransformer(styleSource)on every invocation — once per output file.newTransformer(source)compiles the XSL stylesheet from scratch each time. For large FIX versions (e.g. FIX Latest) with hundreds of message/component/field files, the same handful of XSL stylesheets were being compiled hundreds of times unnecessarily.Changes
quickfixj-codegenerator/src/main/java/org/quickfixj/codegenerator/MessageCodeGenerator.javaTransformerFactory— moved from a local variable insidecreateTransformer()to afinalinstance field so Saxon is initialised once perMessageCodeGeneratorinstance.Templatescache — added aConcurrentHashMap<String, Templates>instance field. Ajavax.xml.transform.Templatesobject is a thread-safe, pre-compiled representation of an XSL stylesheet."classpath:" + xsltFile.transformerFactory.newTemplates(styleSource)and stores the result. Subsequent calls reuse the cachedTemplatesand call the cheaptemplates.newTransformer()to get a fresh (non-thread-safe)Transformerinstance — as required by the JAXP spec.TransformerConfigurationExceptionis still propagated correctly via the existingCodeGenerationExceptionwrapper.What is
styleSource?styleSourceis ajavax.xml.transform.stream.StreamSource— it wraps the raw byte stream of the XSL stylesheet file, loaded either from the filesystem (task.getTransformDirectory()/<file>.xsl) or from the classpath. It is passed once totransformerFactory.newTemplates(styleSource)to compile the stylesheet into a reusableTemplatesobject. After the first compilation for a given stylesheet,styleSourceis no longer needed; all subsequent calls reuse the cachedTemplates.Before / After