Skip to content

Perf: hoist orderAfterMerge out of the parent-plugin loop (#271) - #285

Open
elharo wants to merge 1 commit into
masterfrom
fix/issue-271-merge-plugin-order-perf
Open

Perf: hoist orderAfterMerge out of the parent-plugin loop (#271)#285
elharo wants to merge 1 commit into
masterfrom
fix/issue-271-merge-plugin-order-perf

Conversation

@elharo

@elharo elharo commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #271

Problem

ModelUtils.mergePluginLists() recomputed ModelUtils.orderAfterMerge(...) and
called childContainer.setPlugins(results) / childContainer.flushPluginMap()
on every iteration of the parent-plugin loop, even though the loop body
already accumulates the merged plugins into assembledPlugins.

orderAfterMerge walks both full plugin lists with results.contains/indexOf
linear scans, making the whole merge O(P³) in the worst case for P parent
plugins plus repeated plugin-map flushes. The ordering result is identical
whether computed once at the end or per-iteration.

Fix

Hoist orderAfterMerge(...) + setPlugins/flushPluginMap out of the loop and
compute them once after the loop finishes, using the final assembledPlugins.

Testing

No new tests (performance-only change). All existing tests pass, including the
failsafe integration tests run with -Prun-its (ITSupplementalArtifact
exercises the supplemental-model merge that uses mergePluginLists), plus
spotless/checkstyle/RAT via mvn verify.

@elharo
elharo requested a review from Humbedooh August 2, 2026 14:23
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.

Perf: orderAfterMerge recomputed inside the parent-plugin loop (O(P^3))

1 participant