Skip to content

performance improvement for MessageCodeGenerator and stylesheets - #31

Open
chrjohn wants to merge 1 commit into
masterfrom
perf
Open

chrjohn wants to merge 1 commit into
masterfrom
perf

Conversation

@chrjohn

@chrjohn chrjohn commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Claude's take on performance optimization.

Java changes (MessageCodeGenerator.java)

  1. The dictionary is converted to Saxon's own tree format once per version. Before, every generated file (thousands of them) was transformed from a DOMSource, so Saxon redid the DOM conversion each time. The DOM parse itself, with its security settings, is unchanged; the converted tree is cached next to it. This was the biggest single gain.
  2. Each stylesheet is compiled once. Before, a new TransformerFactory was created and the XSL recompiled for every phase of every version. Now one factory and a cache of compiled stylesheets are used, keyed by the XSL's path, so custom transformDirectory stylesheets still take priority.
  3. Settings that are the same for every file are set once per loop, so only fieldName/itemName changes per file. The utcTimestampPrecision check also moved out of the per-field loop.

Stylesheet changes
4. Fields.xsl: to generate one field, the fix template walked every element of the dictionary, including all messages and components. It now goes straight to fields/field[@name=$fieldName], which removes a cost that grew with the square of the dictionary size.
5. Message.xsl, MessageSubclass.xsl, MessageFactory.xsl: field and component lookups by name, like /fix/fields/field[@name=$name], scanned the whole list every time. They now use xsl:key indexes. The //component[@name=$myname] lookups use a key on all component elements, so they return exactly the same nodes as before.

Custom stylesheets keep working because they receive the same document; only its internal form changed.

FIX50SP2 FIX44 FIX42 Total
Before 36.3s 8.0s 0.8s 45.1s
Java changes only 7.4s 1.6s 0.2s 9.2s
+ stylesheet changes 2.1s 0.3s 0.06s 2.4s

@chrjohn chrjohn added this to the 3.0.4 milestone Oct 30, 2026
@chrjohn chrjohn changed the title performance improvement performance improvement for MessageCodeGenerator and stylesheets Oct 30, 2026
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

Successfully merging this pull request may close these issues.

1 participant