Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update Enumerable.Min/Max for all IBinaryIntegers#96605

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
stephentoub merged 1 commit intodotnet:mainfromstephentoub:enumerableminmax
Jan 8, 2024

Conversation

@stephentoub
Copy link
Member

The implementations are special-casing most of the built-in ones, in order to delegate to the IBinaryInteger-constrained helper, but it was missing Int128, UInt128, and char. ?hese won't be vectorized, but they'll at least use the more streamlined non-vectorized implementations.

The implementations are special-casing most of the built-in ones, in order to delegate to the IBinaryInteger-constrained helper, but it was missing Int128, UInt128, and char. ?hese won't be vectorized, but they'll at least use the more streamlined non-vectorized implementations.
@stephentoubstephentoub added area-System.Linq tenet-performancePerformance related issue labelsJan 8, 2024
@stephentoubstephentoub added this to the9.0.0 milestoneJan 8, 2024
@ghost
Copy link

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

Issue Details

The implementations are special-casing most of the built-in ones, in order to delegate to the IBinaryInteger-constrained helper, but it was missing Int128, UInt128, and char. ?hese won't be vectorized, but they'll at least use the more streamlined non-vectorized implementations.

Author:stephentoub
Assignees:-
Labels:

area-System.Linq,tenet-performance

Milestone:9.0.0

Copy link
Member

@eiriktsarpaliseiriktsarpalis left a comment

Choose a reason for hiding this comment

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

If vectorization isn't available for the new types, what is the primary motivation for making this change? Is it thatIBinaryInteger comparison is generally faster than usingComparer<TDefault>? Or is it simply the fact that we extract the span and avoid allocating an enumerator? If it's the latter case, couldn't this be extracted to the outer method so that it can be applied to all types?

@stephentoub
Copy link
MemberAuthor

Previously a) it was a bit faster and b) IsSupported could ironically only be called with a supported type or else it would throw. But the former was improved in the JIT and the latter was fixed late in 8, so we should be able to make it work with an IComparable-based implementation. The primary benefit is being able to work on the span and avoid the enumerator costs.

@stephentoub
Copy link
MemberAuthor

Althoughhttps://github.com/dotnet/runtime/pull/96570/files#diff-a7055cca652c7bf1b5af1f4f86111a7949edc40480117bf2fd7651b9338458ca needs to be merged first to remove the constraint from TryGetSpan.

@stephentoub
Copy link
MemberAuthor

Since this is a small change, I suggest we merge this, and then we can subsequently look at improving Min/Max to use a span for other types. I have another branch where I'm doing so for more operators and I can incorporate it into that.

eiriktsarpalis reacted with thumbs up emoji

@stephentoubstephentoub merged commit0823c5c intodotnet:mainJan 8, 2024
@stephentoubstephentoub deleted the enumerableminmax branchJanuary 8, 2024 16:34
@stephentoub
Copy link
MemberAuthor

If it's the latter case, couldn't this be extracted to the outer method so that it can be applied to all types?

I gave this a go, and the reliance onComparer<T>.Default yields a tad less efficient code in some of the cases. I'll try to revisit it again later.

agocke added a commit to agocke/runtime that referenced this pull requestJan 12, 2024
PRdotnet#96605 added new generic arguments to the unit tests which need tobe preserved in the rd.xml since the test suite is not yet trim-compatible.
@agockeagocke mentioned this pull requestJan 12, 2024
agocke added a commit that referenced this pull requestJan 13, 2024
PR#96605 added new generic arguments to the unit tests which need tobe preserved in the rd.xml since the test suite is not yet trim-compatible.
tmds pushed a commit to tmds/runtime that referenced this pull requestJan 23, 2024
PRdotnet#96605 added new generic arguments to the unit tests which need tobe preserved in the rd.xml since the test suite is not yet trim-compatible.
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsFeb 9, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@eiriktsarpaliseiriktsarpaliseiriktsarpalis approved these changes

Assignees

@stephentoubstephentoub

Labels

area-System.Linqtenet-performancePerformance related issue

Projects

None yet

Milestone

9.0.0

Development

Successfully merging this pull request may close these issues.

2 participants

@stephentoub@eiriktsarpalis

[8]ページ先頭

©2009-2025 Movatter.jp