Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use HashSet for constant time perf #2002

Merged
merged 1 commit into from
Jan 31, 2024

Conversation

drewnoakes
Copy link
Member

@drewnoakes drewnoakes commented Jan 31, 2024

The PrepareServices method calls GenerateUniqueServiceName for every annotation of every service producer. The previous Contains call is O(N) on the number of resources.

This changes the List<> to a HashSet<> for more even perf across differing numbers of resources.

Microsoft Reviewers: Open in CodeFlow

The `PrepareServices` method calls `GenerateUniqueServiceName` for every annotation of every service producer. The previous `Contains` call is O(N) on the number of resources.

This changes the `List<>` to a `HashSet<>` for more even perf across differing numbers of resources.
@drewnoakes drewnoakes added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Jan 31, 2024
@drewnoakes drewnoakes added this to the preview 4 (Mar) milestone Jan 31, 2024
@davidfowl davidfowl enabled auto-merge (squash) January 31, 2024 03:29
@davidfowl davidfowl merged commit 7e0a098 into dotnet:main Jan 31, 2024
8 checks passed
@drewnoakes drewnoakes deleted the replace-list-with-hash-set branch January 31, 2024 04:31
radical pushed a commit to radical/aspire that referenced this pull request Feb 2, 2024
The `PrepareServices` method calls `GenerateUniqueServiceName` for every annotation of every service producer. The previous `Contains` call is O(N) on the number of resources.

This changes the `List<>` to a `HashSet<>` for more even perf across differing numbers of resources.
radical pushed a commit to radical/aspire that referenced this pull request Feb 6, 2024
The `PrepareServices` method calls `GenerateUniqueServiceName` for every annotation of every service producer. The previous `Contains` call is O(N) on the number of resources.

This changes the `List<>` to a `HashSet<>` for more even perf across differing numbers of resources.
@github-actions github-actions bot locked and limited conversation to collaborators Apr 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants