-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Add more specialized frozen collection types. #79794
Conversation
Tagging subscribers to this area: @dotnet/area-system-collections Issue Details
FrozenDictionary/Set each have some constants defined to drive the heuristics that decide when to use the small and sparse collection types. I did some preliminary tuning of these, but this could use a detailed benchmark to pick the right values. I'll leave the fine-tuning to a separate PR.
|
...stem.Collections.Immutable/src/System/Collections/Frozen/ClosedRangeInt32FrozenDictionary.cs
Outdated
Show resolved
Hide resolved
...stem.Collections.Immutable/src/System/Collections/Frozen/ClosedRangeInt32FrozenDictionary.cs
Outdated
Show resolved
Hide resolved
...ries/System.Collections.Immutable/src/System/Collections/Frozen/ClosedRangeInt32FrozenSet.cs
Outdated
Show resolved
Hide resolved
...ries/System.Collections.Immutable/src/System/Collections/Frozen/ClosedRangeInt32FrozenSet.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenDictionary.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/SmallInt32FrozenSet.cs
Outdated
Show resolved
Hide resolved
...ries/System.Collections.Immutable/src/System/Collections/Frozen/SparseRangeInt32FrozenSet.cs
Outdated
Show resolved
Hide resolved
...ries/System.Collections.Immutable/src/System/Collections/Frozen/SparseRangeInt32FrozenSet.cs
Outdated
Show resolved
Hide resolved
...ries/System.Collections.Immutable/src/System/Collections/Frozen/SparseRangeInt32FrozenSet.cs
Outdated
Show resolved
Hide resolved
...ries/System.Collections.Immutable/src/System/Collections/Frozen/SparseRangeInt32FrozenSet.cs
Outdated
Show resolved
Hide resolved
Is there an issue approving the API - or is this intended to start discussion... |
...ibraries/System.Collections.Immutable/src/System/Collections/Frozen/SmallFrozenDictionary.cs
Outdated
Show resolved
Hide resolved
@danmoseley There is no API change here, all these types are internal to the implementation of the existing frozen set and dictionary. |
...stem.Collections.Immutable/src/System/Collections/Frozen/ClosedRangeInt32FrozenDictionary.cs
Outdated
Show resolved
Hide resolved
78abf93
to
27abcb3
Compare
de2ac98
to
9a0bb73
Compare
...m.Collections.Immutable/src/System/Collections/Frozen/Integer/ClosedRangeIntegerFrozenSet.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenDictionary.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenDictionary.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenDictionary.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenDictionary.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenDictionary.cs
Outdated
Show resolved
Hide resolved
....Collections.Immutable/src/System/Collections/Frozen/Integer/SmallIntegerFrozenDictionary.cs
Outdated
Show resolved
Hide resolved
.../System.Collections.Immutable/src/System/Collections/Frozen/Integer/SmallIntegerFrozenSet.cs
Outdated
Show resolved
Hide resolved
...ibraries/System.Collections.Immutable/src/System/Collections/Frozen/SmallFrozenDictionary.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/SmallFrozenSet.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Collections.Immutable/tests/Frozen/FrozenSetTests.cs
Show resolved
Hide resolved
- Add SmallFrozenDictionary/Set which don't do any hashing and simply iterate through arrays, testing each element - Add ClosedRangeInt32FrozenDictionary/Set which are used when the keys are in a closed integer range. - Add SparseRangeInt32FrozenSet which uses a bit vector for storage. FrozenDictionary/Set each have some constants defined to drive the heuristics that decide when to use the small and sparse collection types. I did some preliminary tuning of these, but this could use a detailed benchmark to pick the right values. I'll leave the fine-tuning to a separate PR.
e2ef0a9
to
31712f6
Compare
dad8b1a
to
2c9fc66
Compare
src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/Constants.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenDictionary.cs
Show resolved
Hide resolved
src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenDictionary.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenSet.cs
Outdated
Show resolved
Hide resolved
...ollections.Immutable/src/System/Collections/Frozen/Int32/ClosedRangeInt32FrozenDictionary.cs
Outdated
Show resolved
Hide resolved
...ollections.Immutable/src/System/Collections/Frozen/Int32/ClosedRangeInt32FrozenDictionary.cs
Outdated
Show resolved
Hide resolved
...es/System.Collections.Immutable/src/System/Collections/Frozen/Int32/Int32FrozenDictionary.cs
Show resolved
Hide resolved
...libraries/System.Collections.Immutable/src/System/Collections/Frozen/Int32/Int32FrozenSet.cs
Show resolved
Hide resolved
...ystem.Collections.Immutable/src/System/Collections/Frozen/Int32/SparseRangeInt32FrozenSet.cs
Outdated
Show resolved
Hide resolved
...m.Collections.Immutable/src/System/Collections/Frozen/Integer/SparseRangeIntegerFrozenSet.cs
Outdated
Show resolved
Hide resolved
<Compile Include="System\Collections\Frozen\Int32\SmallInt32FrozenDictionary.cs" Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))" /> | ||
<Compile Include="System\Collections\Frozen\Int32\SmallInt32FrozenSet.cs" Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))" /> | ||
<Compile Include="System\Collections\Frozen\Int32\SparseRangeInt32FrozenSet.cs" Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These msbuild functions aren't cost-free and we usually try to not have them per compile item. Can you please move them into a separate ItemGroup? Same for the ones above (L39-43).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WIll do.
Add SmallFrozenDictionary/Set which don't do any hashing and simply iterate through arrays, testing each element
Add ClosedRangeInt32FrozenDictionary/Set which are used when the keys are in a closed integer range.
Add SparseRangeInt32FrozenSet which uses a bit vector for storage.
FrozenDictionary/Set each have some constants defined to drive the heuristics that decide when to use the small and sparse collection types. I did some preliminary tuning of these, but this could use a detailed benchmark to pick the right values. I'll leave the fine-tuning to a separate PR.