-
Notifications
You must be signed in to change notification settings - Fork 5.2k
More frozen collection perf, test, and cleanup improvements #81389
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Changed SmallIntegerFrozenDictionary/Set implementations to be based on `IComparable<>` rather than `IBinaryInteger<>`. This enables them to be used with comparable types other than integers and also be used in pre-.NET 7 builds, as well as to simplify consuming code. Codegen isn't quite as good for the types it did work with, but it's good enough (and will hopefully improve in the future. - Removed SmallInt32FrozenDictionary/Set implementations, which as a result of the above changes are no longer needed. - Rewrote FrozenHashtable.Create to avoid creating so many temporary allocations as part of setting up the hashtable. It was creating a list per bucket, which on average would be a list per element. This was not only a lot of allocation but also a significant time sink, with benchmarks showing this can up to halve construction time. - Sorted some .csproj includes - A few more tests to improve code coverage. Line coverage for the Frozen namespace is up to 99.1%.
|
Tagging subscribers to this area: @dotnet/area-system-collections Issue Details
|
src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenDictionary.cs
Show resolved
Hide resolved
...tem.Collections.Immutable/src/System/Collections/Frozen/SmallComparableValueTypeFrozenSet.cs
Show resolved
Hide resolved
...tem.Collections.Immutable/src/System/Collections/Frozen/SmallComparableValueTypeFrozenSet.cs
Outdated
Show resolved
Hide resolved
eiriktsarpalis
approved these changes
Jan 31, 2023
...lections.Immutable/src/System/Collections/Frozen/SmallComparableValueTypeFrozenDictionary.cs
Outdated
Show resolved
Hide resolved
stephentoub
commented
Jan 31, 2023
...tem.Collections.Immutable/src/System/Collections/Frozen/SmallComparableValueTypeFrozenSet.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
IComparable<>rather thanIBinaryInteger<>. This enables them to be used with comparable types other than integers and also be used in pre-.NET 7 builds, as well as to simplify consuming code. Codegen isn't quite as good for the types it did work with, but it's good enough (and will hopefully improve in the future.