slawekjaranowski opened a new pull request, #444: URL: https://github.com/apache/maven-install-plugin/pull/444
* Cache projectsUsingPlugin list to avoid O(N²) reactor scan InstallMojo.execute() computes the list of reactor projects using the install plugin on every module invocation by streaming over all projects and calling getPluginsAsMap() for each one. In a 4383-module reactor, this produces ~19.2M filter evaluations (4383² calls). JFR profiling shows this as 5.6% of total CPU time, all in PluginContainer.getPluginsAsMap() called from usingPlugin(). Fix: cache the computed list in the first reactor project's plugin context on first invocation. The list is invariant during a build — which projects have the install plugin configured does not change between module invocations. This turns O(N²) into O(N). * fix: synchronize cache population for parallel builds The get/check/put on the plugin context map is a TOCTOU race — in parallel builds (-T), multiple threads can see the cache as null and each recompute the full reactor scan, defeating the cache. Wrap the compound operation in synchronized(ctx) so only the first thread computes and all others reuse the result. Session.getPluginContext() returns Map (not ConcurrentMap), so synchronized is the safest choice that does not depend on the underlying implementation. * refactor: use computeIfAbsent instead of synchronized block Replace the synchronized get/check/put with a single computeIfAbsent call. The plugin context map is a ConcurrentHashMap at runtime, so computeIfAbsent is atomic and guarantees single-invocation. Even if the underlying Map implementation changed, the worst case is redundant computation of the same invariant list — a perf regression, not a bug. - https://github.com/apache/maven-install-plugin/pull/427 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
