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

Reduce allocations in AbstractRecommendationServiceBasedCompletionProvider.GetSymbolsAsync #76365

Merged
merged 1 commit into from
Dec 11, 2024

Conversation

ToddGrun
Copy link
Contributor

This method accounts for about 3% of VS allocations during the typing scenario in the csharp editing scrolling speedometer test.

  1. Move the comparer from the Contains call to the Set creation. By having this on the Contains call, the code was actually invoking the Linq overload of contains, fully walking the collection (and creating an enumerator to do so) instead of treating it like a set.

  2. Moved the IsIntrinsic call before the InferredTypes check as it is cheap

  3. Don't invoke the GetSymbolType method if the inferredTypes array is empty.

It's unclear exactly how much gain this will get, but I saw the inferredTypes collection empty often enough that I am expecting somewhere between a 1% and 2% reduction from this.

*** Relevant allocations from speedometer test without this change ***
image

…vider.GetSymbolsAsync

This method accounts for about 3% of VS allocations during the typing scenario in the csharp editing scrolling speedometer test.

1) Move the comparer from the Contains call to the Set creation. By having this on the Contains call, the code was actually invoking the Linq overload of contains, fully walking the collection (and creating an enumerator to do so) instead of treating it like a set.

2) Moved the IsIntrinsic call before the InferredTypes check as it is cheap

3) Don't invoke the GetSymbolType method if the inferredTypes array is empty.

It's unclear exactly how much gain this will get, but I saw the inferredTypes collection empty often enough that I am expecting somewhere between a 1% and 2% reduction from this.
@ToddGrun ToddGrun requested a review from a team as a code owner December 11, 2024 00:59
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants