You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "elharo (via GitHub)" <gi...@apache.org> on 2026/08/02 11:17:54 UTC

[I] Perf: orderAfterMerge recomputed inside the parent-plugin loop (O(P^3)) [maven-remote-resources-plugin]

elharo opened a new issue, #271:
URL: https://github.com/apache/maven-remote-resources-plugin/issues/271

   ## Summary
   `ModelUtils.mergePluginLists()` recomputes `orderAfterMerge(...)` — and calls `setPlugins`/`flushPluginMap` — on **every** iteration of the parent-plugin loop, even though the loop body already accumulates into `assembledPlugins`.
   
   `src/main/java/org/apache/maven/plugin/resources/remote/ModelUtils.java:81-117`
   
   ```java
   for (Plugin parentPlugin : parentPlugins) {
       ...
       // very important to use the parentPlugins List ...
       List<Plugin> results =
               ModelUtils.orderAfterMerge(assembledPlugins, parentPlugins, childContainer.getPlugins());
       childContainer.setPlugins(results);
       childContainer.flushPluginMap();
   }
   ```
   
   `orderAfterMerge` walks both full plugin lists (`:121-163`) with `results.contains`/`indexOf` linear scans.
   
   ## Impact
   For P parent plugins this is O(P³) work in the worst case plus repeated map flushes — mostly negligible for typical plugin counts but quadratic-to-cubic during supplemental-model merges with many plugins. The ordering result is identical whether computed once at the end or per-iteration, so the per-iteration call is pure waste.
   
   ## Suggested fix
   Hoist `orderAfterMerge(...)` + `setPlugins`/`flushPluginMap` out of the loop and compute them once after the loop finishes.


-- 
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: issues-unsubscribe@maven.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Perf: orderAfterMerge recomputed inside the parent-plugin loop (O(P^3)) [maven-remote-resources-plugin]

Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo closed issue #271: Perf: orderAfterMerge recomputed inside the parent-plugin loop (O(P^3))
URL: https://github.com/apache/maven-remote-resources-plugin/issues/271


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org