Skip to content

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

Merged
Rongmario merged 1 commit into
CleanroomMC:mainfrom
romanfedyniak:main
Jul 17, 2026
Merged

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

Conversation

@romanfedyniak

@romanfedyniak romanfedyniak commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

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

@romanfedyniak romanfedyniak reopened this Jul 2, 2026
@Rongmario
Rongmario merged commit 503fae9 into CleanroomMC:main Jul 17, 2026
2 checks passed
baka-gourd pushed a commit that referenced this pull request Jul 17, 2026
- It is likely that ASMDataTable + the class scanner will be rewritten at a later date!
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