Skip to content

perf: DataDictionaryGenerator — buffer output, cache JAXBContext and XPathExpression - #68

Draft
chrjohn with Copilot wants to merge 4 commits into
masterfrom
copilot/improve-code-generation-performance
Draft

chrjohn with Copilot wants to merge 4 commits into
masterfrom
copilot/improve-code-generation-performance

Conversation

Copilot AI commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

DataDictionaryGenerator repeated three expensive operations on every generation run: unbuffered file I/O, JAXBContext.newInstance() (classpath scan + reflection), and XPathFactory/XPath/compile() setup. None of these need to happen more than once.

Changes

  • Buffered I/O — wrap FileWriter in BufferedWriter inside writeFile(), batching OS write calls (mirrors existing CodeGeneratorJ pattern)
  • Cache JAXBContext — introduce static final JAXB_CONTEXT, eliminating two per-call JAXBContext.newInstance() invocations in generate(Repository, File) and unmarshal()
  • Cache XPathExpression — introduce static final REQUIRED_GROUP_REF_XPATH, compiling //fixr:groupRef[@presence='required'] and its namespace context once at class load instead of on every getRequiredGroups() call

Copilot AI added 2 commits July 17, 2026 07:49
- Wrap FileWriter with BufferedWriter in writeFile() to reduce unbuffered OS write calls
- Cache JAXBContext as a static final field, replacing per-call JAXBContext.newInstance() in both generate(Repository,File) and unmarshal()
- Cache compiled XPathExpression as a static final field (REQUIRED_GROUP_REF_XPATH), replacing per-call XPathFactory/XPath/compile() in getRequiredGroups()
Copilot AI changed the title perf: improve DataDictionaryGenerator performance by caching JAXBContext, XPath expression, and buffering file output perf: DataDictionaryGenerator — buffer output, cache JAXBContext and XPathExpression Jul 17, 2026
Copilot AI requested a review from chrjohn July 17, 2026 13:43
@chrjohn chrjohn closed this Jul 17, 2026
@chrjohn chrjohn reopened this Jul 17, 2026
… duplication

Extract the repeated char[]-fill-new String(...) pattern into a private
static buildIndent(int level) method, used by both the INDENTS static
initializer and the indent() fallback path.
@chrjohn chrjohn removed this from the 1.0.4 milestone Aug 27, 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.

2 participants