You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
ViolationSuppressor.XPATH_SUPPRESSOR.suppressOrNull() creates and compiles a new SaxonXPathRuleQuery for every candidate violation. For the same rule and file, this repeatedly initializes Saxon and compiles the same violationSuppressXPath.
Creating the query calls Configuration.newConfiguration(), registers the language extension functions, compiles the expression with XPathEvaluator.createExpression(), and analyzes it for Rule Chain use. With N candidate violations, all of that currently runs N times. Reusing the query would reduce the compilation work to once while still evaluating the XPath for every node. I haven't measured the end-to-end speedup yet, but this should remove repeated setup work from rules that produce many candidate violations.
Describe the solution you'd like
Cache the compiled query per rule and file, then reuse it for each node evaluation. The cache should stay lazy and must account for the rule properties and language-specific XPath handler, not just the XPath string.
A test could process many violations from one rule and verify that the query is compiled once without changing the suppression results.
Additional context
I found this on main at 6c8bbe8df970acb04d4d5fa788318d1350b9b7a9. The existing TODO in ViolationSuppressor also says the XPath should be parsed only once.
This is a focused follow-up to the postponed suppression work discussed in #1676. It is also related to the broader Saxon initialization cost reported in #6155.
Activity
aoto-tech commentedon Sep 14, 2026
[core] Fix pmd#7072: Reuse compiled violationSuppressXPath queries (p…