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

Small allocation optimization in StateTable.Builder.ToImmutable #72364

Merged

Conversation

ToddGrun
Copy link
Contributor

@ToddGrun ToddGrun commented Mar 2, 2024

Use an ArrayBuilder as a scratch buffer instead of allocating an array every time. Small allocation that barely showed up in the RichCopyTest speedometer test.

*** Previous allocations
image

…tch buffer in StateTable.Builder.ToImmutable
@ToddGrun ToddGrun requested a review from a team as a code owner March 2, 2024 01:07
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 2, 2024
@ToddGrun
Copy link
Contributor Author

ToddGrun commented Mar 2, 2024

Debated not making this change, but it was simple and safe enough that I figured it was worth it

Free scratch array back to pool
@ToddGrun
Copy link
Contributor Author

ToddGrun commented Mar 5, 2024

@dotnet/roslyn-compiler -- ptal

@ToddGrun
Copy link
Contributor Author

ToddGrun commented Mar 6, 2024

waiting on #72395 as it will provide a cleaner way to do this

@ToddGrun
Copy link
Contributor Author

waiting on #72395 as it will provide a cleaner way to do this

Modified this PR to now use SegmentedCollectionsMarshal.GetValueRefOrNullRef instead of a scratch array.

@ToddGrun ToddGrun merged commit 9baba7e into dotnet:main Mar 21, 2024
24 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Mar 21, 2024
@RikkiGibson RikkiGibson modified the milestones: Next, 17.10 P3 Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants