KEMBAR78
More frozen collection perf, test, and cleanup improvements by stephentoub · Pull Request #81389 · dotnet/runtime · GitHub
Skip to content

Conversation

stephentoub
Copy link
Member

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

- 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%.
@ghost
Copy link

ghost commented Jan 30, 2023

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

Issue Details
  • 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%.
Author: stephentoub
Assignees: -
Labels:

area-System.Collections

Milestone: 8.0.0

Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
@stephentoub stephentoub merged commit 051fc45 into dotnet:main Jan 31, 2023
@stephentoub stephentoub deleted the morefrozen branch January 31, 2023 17:49
@ghost ghost locked as resolved and limited conversation to collaborators Mar 2, 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.

2 participants