[FIRRTL][Dedup] Alter dedup group handling, avoid exponential behavior. #6985
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Transmute these annotations to simple (temporary) attributes on modules.
This causes the desired behavior for hashing and since this must match, when deduplicating no work is needed.
Presently, as annotations, each module dedup'd into the group walks all annotations and "adds context" (makes them non-local) and interns a new annotation array with those annotations. At the end of the pass, all dedupGroup annotations are removed.
This causes a lot of unnecessary symbols, hierpaths, annotations, and arrays of annotations as well as some quadratic behavior.
DedupGroup annotations are commonly on every single module, so for those designs large dedup groups scaled poorly.
Instead, drop these annotations immediately and add as a simple named attribute indicating the group.
Drop the (temporary) dedup group attributes at end of pass, as they are just an in-IR way to track this per-module during the pass.
Fixes #6979.
Benchmarking (n=10, median) on some quick synthetic examples put together, FWIW (top has instances of the many identical empty modules):
Significantly improves performance where there are many instances of deduplicated modules and there are dedup group annotations.