Skip to content

Fix quadratic handling of Definitions - #5506

Merged
jackkoenig merged 2 commits into
mainfrom
jackkoenig/fix-definition-linear-search
Oct 5, 2026
Merged

jackkoenig merged 2 commits into
mainfrom
jackkoenig/fix-definition-linear-search

Conversation

@jackkoenig

@jackkoenig jackkoenig commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fix quadratic handling of Definitions

  1. Linear search for every Instance construction; instead use a new DefinitionRegistry which uses separate HashSets for the different datastructures we need to search
  2. Redundantly adding Definitions to parent dynamic context (we were already sharing the same definitions datastructure)

The reason we had the linear search for (1) is that we were searching several different types of Definitions which made the obvious solution of "use a HashSet" not work. Instead, we need 3 HashSets which are now encapsulated in DefinitionRegistry.

Release Notes

This significantly improves performance for designs with many Definitions and many Instances.

Development notes

  • AI tool(s) used: Opencode (GPT-6.1 Sol)
  • Merge strategy (defaults to squash): squash

Create a new DefinitionRegistery to handle the different sorts of
definitions as multiple HashSets.
They may still be elaborating when we need to look up other modules.
@jackkoenig
jackkoenig requested review from azidar and mwachs5 October 5, 2026 21:20
@jackkoenig jackkoenig added the Performance Improves performance, will be included in release notes label Oct 5, 2026
@jackkoenig
jackkoenig merged commit a2d6631 into main Oct 5, 2026
30 of 31 checks passed
@jackkoenig
jackkoenig deleted the jackkoenig/fix-definition-linear-search branch October 5, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Performance Improves performance, will be included in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants