Skip to content

Stabilize ModuleDependency descriptions#1648

Open
DragonFSKY wants to merge 2 commits into
TNG:mainfrom
DragonFSKY:fix-module-dependency-description-order
Open

Stabilize ModuleDependency descriptions#1648
DragonFSKY wants to merge 2 commits into
TNG:mainfrom
DragonFSKY:fix-module-dependency-description-order

Conversation

@DragonFSKY

Copy link
Copy Markdown

Fixes #1630.

This makes ModuleDependency#getDescription() render its underlying class dependencies in their natural Dependency order, instead of relying on the iteration order of the backing set. The collected dependencies are unchanged; only the textual report output is stabilized.

A regression test verifies that the rendered description follows the same sorted dependency order.

Tested with:

./gradlew :archunit:test --tests com.tngtech.archunit.library.modules.ModuleDependencyTest

@DragonFSKY
DragonFSKY force-pushed the fix-module-dependency-description-order branch 2 times, most recently from f934965 to 13ac918 Compare July 1, 2026 02:06
@hankem

hankem commented Jul 9, 2026

Copy link
Copy Markdown
Member

Thank you so much for your contribution, and first of all sorry for the late feedback!

The only thing I'd like to test is how much sorting affects the performance, but other than that, I have no concerns that we can integrate your fix soon.

@DragonFSKY
DragonFSKY force-pushed the fix-module-dependency-description-order branch from 4c68455 to c47468c Compare July 17, 2026 09:33
Sort class dependency descriptions before rendering a module dependency so the text remains stable across set iteration orders.

Issue: TNG#1630
Signed-off-by: DragonFSKY <38503900+DragonFSKY@users.noreply.github.com>
Signed-off-by: DragonFSKY <38503900+DragonFSKY@users.noreply.github.com>
@DragonFSKY
DragonFSKY force-pushed the fix-module-dependency-description-order branch from c47468c to 77dfee9 Compare July 17, 2026 09:36
@DragonFSKY

Copy link
Copy Markdown
Author

Thanks for taking a look, and no worries about the timing! I fixed the DCO issue and normalized both commits to the same GitHub identity/sign-off.

I also ran a targeted local benchmark on JDK 25 using real ModuleDependency instances built from ArchUnit classes. It compared the previous unsorted description rendering with the sorted rendering in this PR; the figures below are medians from seven alternating rounds:

Class dependencies Unsorted Sorted Added time
81 17.3 us 22.0 us 4.7 us
926 126.4 us 455.7 us 329.3 us
5,449 1.35 ms 3.41 ms 2.05 ms

So the relative cost is visible for large dependency sets, but the absolute overhead stayed around 2 ms even for the largest real module dependency in this sample, and it is limited to the getDescription/reporting path. I hope this helps with the performance assessment.

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.

Nondeterministic violation description for ModuleDependency: leads to failing test when used as frozen rule

2 participants