-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Improve SpanHelpers.IndexOfAny(byte,byte) #40747
Improve SpanHelpers.IndexOfAny(byte,byte) #40747
Conversation
f7652c5
to
6e7f28e
Compare
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.
Typo.
src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Byte.cs
Outdated
Show resolved
Hide resolved
…te.cs Co-authored-by: Günther Foidl <[email protected]>
src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Byte.cs
Outdated
Show resolved
Hide resolved
…te.cs Co-authored-by: Dan Moseley <[email protected]>
@benaadams @sebastienros is there a way to quantify how much it would help Kestrel? Would help prioritize review. |
lengthToExamine = ((nuint)(uint)length - offset); | ||
goto SequentialScan; | ||
} | ||
if (!TryFindFirstMatchedLane(mask, matches, ref matchedLane)) |
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.
Thanks for doing this for ARM as well.
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.
LGTM. Thanks for doing this.
// >= Sse2 intrinsics are supported, and length is enough to use them so use that path. | ||
// We jump forward to the intrinsics at the end of the method so a naive branch predict | ||
// will choose the non-intrinsic path so short lengths which don't gain anything aren't | ||
// overly disadvantaged by having to jump over a lot of code. Whereas the longer lengths | ||
// more than make this back from the intrinsics. |
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.
Beautiful comment; thank you.
@sebastienros do you expect this to materially improve Plaintext, given data above? |
We can hope it doesn't make it slower! Ideally any perf related work should be measured before merged, even more that close to rc. We'll have to look at the charts once the build is available. We can also do a custom with the next build containing this change. I'll follow the CI. |
I recommended to @kunalspathak that we go ahead and merge, but good point, @sebastienros. Thanks for checking on it. |
@benaadams thank you for another great improvement! @kunalspathak big thanks for reviewing and merging the PR! |
The better approached used in #40729
Will effect header parsing in Kestrel
/cc @adamsitnik @danmosemsft