Skip to content

[core] Reuse compiled violationSuppressXPath queries #7072

Closed

Description

@aoto-tech

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

  1. added
    an:enhancement
    on Sep 14, 2026
  2. aoto-tech commented on Sep 14, 2026

    @aoto-tech
    Author
  3. added this to the 7.29.0 milestone on Oct 8, 2026
  4. added a commit that references this issue on Oct 23, 2026
    352fff9
  5. added
    for:performance
    on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    an:enhancementfor:performance

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions