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

Add more specialized frozen collection types. #79794

Merged
merged 2 commits into from
Jan 9, 2023
Merged

Conversation

geeknoid
Copy link
Member

  • 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.

@ghost
Copy link

ghost commented Dec 18, 2022

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

Issue Details
  • 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.

Author: geeknoid
Assignees: -
Labels:

area-System.Collections

Milestone: -

@geeknoid geeknoid changed the title Add 5 more specialized frozen collection types. Add 7 more specialized frozen collection types. Dec 18, 2022
@danmoseley
Copy link
Member

Is there an issue approving the API - or is this intended to start discussion...

@geeknoid
Copy link
Member Author

@danmoseley There is no API change here, all these types are internal to the implementation of the existing frozen set and dictionary.

@geeknoid geeknoid force-pushed the main branch 2 times, most recently from 78abf93 to 27abcb3 Compare December 22, 2022 05:29
@build-analysis build-analysis bot mentioned this pull request Dec 22, 2022
@geeknoid geeknoid force-pushed the main branch 2 times, most recently from de2ac98 to 9a0bb73 Compare December 22, 2022 18:15
- 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.
@geeknoid geeknoid force-pushed the main branch 8 times, most recently from e2ef0a9 to 31712f6 Compare January 4, 2023 23:22
@geeknoid geeknoid changed the title Add 7 more specialized frozen collection types. Add more specialized frozen collection types. Jan 4, 2023
@geeknoid geeknoid force-pushed the main branch 2 times, most recently from dad8b1a to 2c9fc66 Compare January 5, 2023 02:42
@geeknoid geeknoid merged commit dcda1e0 into dotnet:main Jan 9, 2023
Comment on lines +47 to +49
<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'))" />
Copy link
Member

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).

Copy link
Member Author

Choose a reason for hiding this comment

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

WIll do.

@ghost ghost locked as resolved and limited conversation to collaborators Feb 9, 2023
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.

7 participants