Skip to content

Cache projectsWithDeployExecution to fix O(N²) reactor scan - #684

Open
gnodet wants to merge 1 commit into
masterfrom
quick-fix/cache-projects-with-deploy
Open

Cache projectsWithDeployExecution to fix O(N²) reactor scan#684
gnodet wants to merge 1 commit into
masterfrom
quick-fix/cache-projects-with-deploy

Conversation

@gnodet

@gnodet gnodet commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Cache the projectsWithDeployExecution list in the first reactor project's plugin context on first invocation
  • Simplify allProjectsMarked() to only check projects that actually have deploy executions
  • The list is invariant during a build — reduces O(N²) to O(N) total

Problem

DeployMojo.allProjectsMarked() calls hasDeployExecution() for every reactor project on every module invocation. hasDeployExecution() calls getPluginsAsMap() for each project. In a 4383-module reactor, this produces O(N²) evaluations.

Same pattern as the install plugin — both discovered via JFR profiling of a large Maven 4 reactor build.

Test plan

  • All 21 existing tests pass
  • Verify on a large multi-module reactor build

🤖 Generated with Claude Code

DeployMojo.allProjectsMarked() calls hasDeployExecution() for every
reactor project on every module invocation. hasDeployExecution() calls
getPluginsAsMap() for each project, producing O(N²) evaluations in a
large reactor build (e.g., 4383² ≈ 19.2M calls in a 4383-module project).

Fix: cache the filtered list of projects with deploy executions in the
first reactor project's plugin context. The list is invariant during a
build. Also simplify allProjectsMarked() to only check the projects
that actually have deploy executions, rather than iterating the full
reactor and testing the disjunction (hasState || !hasDeployExecution).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant