Improve SpanHelpers.IndexOfAny(byte,byte)#40747
Conversation
f7652c5 to
6e7f28e
Compare
…te.cs Co-authored-by: Günther Foidl <gue@korporal.at>
…te.cs Co-authored-by: Dan Moseley <danmose@microsoft.com>
|
@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.
Thanks for doing this for ARM as well.
kunalspathak
left a comment
There was a problem hiding this comment.
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.
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