Reduce allocations in AbstractAsynchronousTaggerProvider.ComputeDifference #75639
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.
This method is showing up in a speedometer typing profile I'm looking at. This method computes the difference between two TagSpanIntervalTrees given an updated snapshot.
To do so, it currently creates a new heap allocated TagSpan for each item in both given interval trees. However, it need not do that, as that generated TagSpan isn't passed out of this method. Instead, TagSpanIntervalTree now has an AddAllSpans method that populates to a collection of value tuples, which ComputeDifference can now use.
This doesn't save a ton of allocations, but it's fairly simple and contained. The amount of allocations reduced by this change varies from 0.1% to 0.5% in a typing scenario I'm looking at depending on the profile.
*** allocations that are removed from the worse of the profiles of a typing scenarios in a speedometer test ***