-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Port SpanHelpers.SequenceCompareTo(ref byte, int, ref byte, int) to Vector128/256 #73475
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e2c60f3
port SpanHelpers.SequenceCompareTo(ref byte, int, ref byte, int)
adamsitnik 55d86e2
try to fix arm64 performance regression by not calling ExtractMostSig…
adamsitnik 13db03f
perform only one comparison when there is no mismatch
adamsitnik f565f58
how about now?
adamsitnik eb22170
remove the comment
adamsitnik 3506efd
Merge branch 'dotnet:main' into spanSequenceCompareTo
adamsitnik 1c31e15
Merge remote-tracking branch 'upstream/main' into spanSequenceCompareTo
adamsitnik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
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.
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.
Isn't this replacing the vectorized detection of which element in the vector differed with a linear walk through all bytes in the vector? If so, did you validate the perf impact of this on inputs smaller than 512 elements? I'm surprised this wouldn't result in regressions.
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.
@stephentoub please excuse me for the delay. That is true, as
Vector128
code path is also executed for arm64, whereExtractMostSignificantBits
is expensive. I've usedBytewiseCheck
which was so far used byVector<T>
code path and its perf is OK.I've added benchmarks for smaller collection sizes, synced the fork and re-run them.
x64 AVX2 (Vector256)
It's more or less on par.
x64 AVX (Vector128)
It's 2-3% slower, but it translates to just +- 0.2ns.
Arm64 AdvSimd (Vector128)
For cases where the inputs are different the perf remains the same, but we can observe a nice boost for equal imputs >= 8 elements (20% to even x3)