Skip to content

Change tagging to free a SegmentedList back to a pool#75873

Merged
ToddGrun merged 1 commit intodotnet:mainfrom
ToddGrun:dev/toddgrun/TaggersUseYieldReturnToKeepSegmentedListInPool
Nov 12, 2024
Merged

Change tagging to free a SegmentedList back to a pool#75873
ToddGrun merged 1 commit intodotnet:mainfrom
ToddGrun:dev/toddgrun/TaggersUseYieldReturnToKeepSegmentedListInPool

Conversation

@ToddGrun
Copy link
Contributor

The GetTags calls into our taggers require passing back an IEnumerable. Previously, we created a SegmentedList to hold all the data and then passed that back. However, that suffers from not being able to add back the returned list into a pool. Instead, switch to using yield return over the populated segmented list as that will allow the list to be freed back to the pool upon completion.

Utilizing the yield state machinery does incur an allocation, but this should be a much smaller allocation than the potentially very large arrays that our taggers were returning.

The GetTags calls into our taggers require passing back an IEnumerable. Previously, we created a SegmentedList to hold all the data and then passed that back. However, that suffers from not being able to add back the returned list into a pool. Instead, switch to using yield return over the populated segmented list as that will allow the list to be freed back to the pool upon completion.

Utilizing the yield state machinery does incur an allocation, but this should be a much smaller allocation than the potentially very large arrays that our taggers were returning.
@ToddGrun ToddGrun requested a review from a team as a code owner November 12, 2024 19:26
@ghost ghost added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Nov 12, 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.

3 participants