Skip to content

Cache the MathML DTD per thread - #1477

Merged
jmdowrick merged 13 commits into
cellml:mainfrom
agarny:issue1476
Dec 3, 2026
Merged

jmdowrick merged 13 commits into
cellml:mainfrom
agarny:issue1476

Conversation

@agarny

@agarny agarny commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Fixes #1476.

Copilot AI lite review requested due to automatic review settings September 28, 2026 06:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The cached DTD can outlive libxml2 cleanup and be reused after parser-global state is torn down.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

Caches the parsed MathML DTD per thread to reduce repeated parsing during validation.

Changes:

  • Adds an RAII wrapper for the parsed DTD.
  • Reuses the DTD through thread-local storage.
File Summary
src/​xmldoc.cpp Implements thread-local MathML DTD caching.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/xmldoc.cpp Resolved
Remove `xmlCleanupParser()` from `XmlDoc::parse` and `XmlDoc::parseMathML` because it is a process-wide libxml2 teardown API that should only run when libxml2 is no longer needed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The cached DTD lifetime is not safe across xmlCleanupParser() calls.

Review effort: Lite
Findings: None

Resolved since last review (1)

This change clarifies the MathML DTD cache lifetime and removes explicit xmlCleanupParser() calls from the libxml parser tests.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Add coverage for concurrent validation and thread-exit cleanup.

Review effort: Lite
Findings: None

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved libxml initialization race and insufficient synchronization in the concurrency test.

Review effort: Lite
Findings: 1 High severity

Open (1)

Comment thread src/xmldoc.cpp Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved blocking issues were identified.

Review effort: Lite
Findings: None

Resolved since last review (1)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The library target may fail to link on platforms where pthreads is separate; propagate Threads::Threads.

Review effort: Lite
Findings: 1 High severity

Open (1)

Comment thread src/xmldoc.cpp Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Address the DTD input-buffer leak, stale CMake cache results, and missing test synchronization.

Review effort: Lite
Findings: None

Resolved since last review (1)

@agarny
agarny requested a lite review from Copilot September 28, 2026 10:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved review comments were identified.

Review effort: Lite
Findings: None

@hsorby hsorby left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some comments on the comments, other than that the code looks and works fine.

Comment thread src/CMakeLists.txt Resolved
Comment thread src/CMakeLists.txt Resolved
Comment thread src/xmldoc.cpp Resolved
Comment thread src/xmldoc.cpp Resolved
Comment thread src/xmldoc.cpp Resolved
@agarny
agarny requested a review from hsorby December 3, 2026 02:12
@jmdowrick
jmdowrick merged commit 1e0e8dc into cellml:main Dec 3, 2026
14 checks passed
@agarny
agarny deleted the issue1476 branch December 3, 2026 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cache the MathML DTD per thread

4 participants