-
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
PGO: Profiled SequenceEqual #96571
PGO: Profiled SequenceEqual #96571
Conversation
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsExtends #96311 to cover memcmp idiom ( bool result = SequenceEqual(dst, src, len); is optimized to: bool result;
if (len == 10) // PGO data
result = SequenceEqual(dst, src, 10); // unrolled
else
result = SequenceEqual(dst, src, len); // fallback Benchmark:public static IEnumerable<object[]> Data()
{
yield return new object[] { new int[2], new int[2] };
yield return new object[] { new int[10], new int[10] };
yield return new object[] { new int[16], new int[16] };
yield return new object[] { new int[32], new int[32] };
}
[Benchmark]
[ArgumentsSource(nameof(Data))]
public bool Compare(int[] a, int[] b) => a.AsSpan().SequenceEqual(b);
|
/azp run runtime-coreclr pgo, runtime-coreclr libraries-pgo, runtime-coreclr pgostress |
Azure Pipelines successfully started running 3 pipeline(s). |
@AndyAyersMS @dotnet/jit-contrib PTAL |
Leaving Memset idiom for future, because it's currently not a call, but |
Extends #96311 to cover memcmp idiom (
SpanHelpers.SequenceEqual
):is optimized to:
Benchmark 1:
Benchmark 2: