Skip to content

Reduce allocations in C# when deserializing lists and arrays #2688

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

Merged
merged 3 commits into from
May 5, 2025

Conversation

kazimuth
Copy link
Contributor

@kazimuth kazimuth commented May 1, 2025

Description of Changes

Since we know the size of lists and arrays, we can allocate them up-front. This also skips allocating an IEnumerable.

API and ABI breaking changes

N/A

Expected complexity level and risk

0

Testing

Automated tests should break immediately if this is wrong

@kazimuth kazimuth requested a review from joshua-spacetime May 1, 2025 16:05
Copy link
Collaborator

@joshua-spacetime joshua-spacetime left a comment

Choose a reason for hiding this comment

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

Can you add a comment to make sure we don't revert this change in the future

@kazimuth kazimuth requested a review from rekhoff May 2, 2025 21:08
Copy link
Contributor

@rekhoff rekhoff left a comment

Choose a reason for hiding this comment

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

Make sense to me, save an allocation :) I see no issues with this. Approved!

@CLAassistant
Copy link

CLAassistant commented May 3, 2025

CLA assistant check
All committers have signed the CLA.

@kazimuth kazimuth force-pushed the jgilles/perf/dont-amortize branch from d986f2e to 06db18d Compare May 5, 2025 16:41
@bfops bfops added release-any To be landed in any release window performance A PR/Issue related to improving performance of stdb labels May 5, 2025
@kazimuth kazimuth added this pull request to the merge queue May 5, 2025
Merged via the queue into master with commit 7dddee9 May 5, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance A PR/Issue related to improving performance of stdb release-any To be landed in any release window
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants