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 CSharpSyntaxFacts.AppendMembers (again) #74790

Merged
merged 6 commits into from
Aug 21, 2024

Conversation

ToddGrun
Copy link
Contributor

A recent change(#74596) modified this code to take in an ArrayBuilder to allow callers to easily use pooled arrays. However, the size of the data populated into those arrays commonly exceeds the ArrayBuilder reuse threshold, those reducing the allocation benefit realized in those codepaths.

This PR changes the callers to instead use a pooled list, thus avoiding the threshold issue. Current scrolling speedometer results for the typing scenario still show this as allocating around 35 MB (which was about 3.5% at the time of the earlier PR, about 4.6% of allocations currently). My hope is that this PR will get rid of nearly all those allocations this time.

*** relevant allocations from the typing scenario in the scrolling speedometer ***
image

A recent change(dotnet#74596) modified this code to take in an ArrayBuilder to allow callers to easily use pooled arrays. However, the size of the data populated into those arrays commonly exceeds the ArrayBuilder reuse threshold, those reducing the allocation benefit realized in those codepaths.

This PR changes the callers to instead use a pooled list, thus avoiding the threshold issue. Current scrolling speedometer results for the typing scenario still show this as allocating around 35 MB (which was about 3.5% at the time of the earlier PR). My hope is that this PR will get rid of nearly all those allocations this time.
@ToddGrun ToddGrun requested review from a team as code owners August 16, 2024 17:47
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 16, 2024
@ToddGrun ToddGrun changed the title Reduce usage in CSharpSyntaxFacts.AppendMembers (again) Reduce allocations in CSharpSyntaxFacts.AppendMembers (again) Aug 16, 2024
@333fred
Copy link
Member

333fred commented Aug 16, 2024

@ToddGrun were you going to run a smoke test for this one?

@ToddGrun
Copy link
Contributor Author

ToddGrun commented Aug 16, 2024

were you going to run a smoke test for this one?

Yeah, I was going to post once the PR was created, but here's the pipeline run that will be generating the PR shortly: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=10060803&view=results

Update: Numbers look a bit wonky to me. Going to make a tweak and re-run the process.

Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compiler changes LGTM.

…*, this will finally get the allocation reductions, as having each caller own what pool they use was giving me grief.
Copy link
Contributor

@RikkiGibson RikkiGibson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compilers changes LGTM

@ToddGrun
Copy link
Contributor Author

Numbers look a bit wonky to me. Going to make a tweak and re-run the process.

Did multiple insertion PRs after the last commit, all looks good now. The full 3.5% of SyntaxNode[] allocations look to be gone.

https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/573228
https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/573250

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.

5 participants