Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

vcsjones
Copy link
Member

@vcsjones vcsjones commented Jan 17, 2024

The OidCollection class starts off with an internal array size of zero, then adjusts to 4, then adjusts to growing by a factor of 2. However, In many cases, we know the size of the OidCollection prior to it being created. In this scenario, we waste two calls to Array.Resize if the collection size is greater than 4, or one call if it is less than or equal to 4.

This pull request adds an internal size hint to the OidCollection so the backing array is appropriately sized from the beginning, and uses it in places where it is suitable to do so.

@ghost ghost assigned vcsjones Jan 17, 2024
@ghost ghost added the area-System.Security label Jan 17, 2024
@ghost
Copy link

ghost commented Jan 17, 2024

Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

Issue Details

The OidCollection class starts off with an internal array size of zero, then adjusts to 4, then adjusts to growing by a factor of 2. However, In many cases, we know the size of the OidCollection prior to it being created. In this scenario, we waste two calls to Array.Resize if the collection size is greater than 4, or one call if it is less than or equal to 4.

This pull request adds an internal size hint to the OidColleciton so the backing array is appropriated sized from the beginning, and uses it in places where it is suitable to do so.

Author: vcsjones
Assignees: vcsjones
Labels:

area-System.Security

Milestone: -

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

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

LGTM. Is this the conversation we had late last year about some perf problem that would be solved by avoiding growing the collection, or am I misremembering?

@vcsjones
Copy link
Member Author

Is this the conversation we had late last year about some perf problem that would be solved by avoiding growing the collection, or am I misremembering?

I think you are misremembering. However I may be misremembering you misremembering.

@stephentoub stephentoub merged commit a7b63ae into dotnet:main Jan 18, 2024
@vcsjones vcsjones deleted the oidcollection-perf branch January 18, 2024 16:08
tmds pushed a commit to tmds/runtime that referenced this pull request Jan 23, 2024
@vcsjones vcsjones added this to the 9.0.0 milestone Jan 24, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants