Skip to content

Speed up ASMDataTable.getAnnotationsFor (O(n^2) -> O(n))#582

Open
romanfedyniak wants to merge 1 commit into
CleanroomMC:mainfrom
romanfedyniak:main
Open

Speed up ASMDataTable.getAnnotationsFor (O(n^2) -> O(n))#582
romanfedyniak wants to merge 1 commit into
CleanroomMC:mainfrom
romanfedyniak:main

Conversation

@romanfedyniak

@romanfedyniak romanfedyniak commented Jul 2, 2026

Copy link
Copy Markdown

Found this while profiling a ~200-mod pack's startup with flare:
getAnnotationsFor was re-filtering the entire annotation table once per mod (Guava's Multimaps.filterValues + ImmutableSetMultimap.copyOf re-scanning everything on every call), which added up to ~19s of CPU time during preInit for no real reason.

Swapped it for a single grouping pass over the annotation table, then an O(1) lookup per container - same equality check as before (File from ModContainer.getSource()), just done once instead of once-per-mod. Same caching, same public behavior.

Before flare profiles:
before
After:
after

@Rongmario

Copy link
Copy Markdown
Member

Well known fix that can be pulled in, but a word of warning is that this will likely be redundant as the cleanmix branch may override this

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.

2 participants