GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [core] Reuse compiled violationSuppressXPath queries · Issue #7072 · pmd/pmd

[core] Reuse compiled violationSuppressXPath queries #7072

New issue
Copy link
New issue
Copy link
Closed
#7073
Closed
[core] Reuse compiled violationSuppressXPath queries#7072
#7073
Copy link
Labels
an:enhancementAn improvement on existing features / rulesfor:performanceThe goal of this change is to improve PMD's performance
Milestone
7.29.0

Description

@aoto-tech
aoto-tech
opened on Sep 14, 2026
Issue body actions

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. aoto-tech
    added
    an:enhancementAn improvement on existing features / rules
    on Sep 14, 2026
  2. aoto-tech commented on Sep 14, 2026

    @aoto-tech
    aoto-tech
    on Sep 14, 2026 · Hidden as off-topic
    Author
    show commentMore actions
  3. UncleOwen
    added this to the 7.29.0 milestone on Oct 8, 2026
  4. adangel
    closed this as completedin #7073on Oct 23, 2026
  5. adangel
    added a commit that references this issue on Oct 23, 2026

    [core] Fix pmd#7072: Reuse compiled violationSuppressXPath queries (p…

    This issue will close once commit 352fff9 is merged into the 'main' branch.
    352fff9
  6. adangel
    added
    for:performanceThe goal of this change is to improve PMD's 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:enhancementAn improvement on existing features / rulesfor:performanceThe goal of this change is to improve PMD's performance

    Type

    No type

    Projects

    No projects

      Milestone

      • 7.29.0

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.