-
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
JIT: Unroll more Equals/StartsWith/EndsWith on arm64 #109036
Conversation
@EgorBot -arm64 --envvars DOTNET_JitDisasm:Bestcase_IgnoreCase using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
public class Bench
{
string s = "https://pkgs.dev.azure.com/dnceng/public/packaging/dotnet10/";
[Benchmark]
public bool Bestcase() =>
s.StartsWith("https://pkgs.dev.azure.com/dnceng/public/pack", StringComparison.Ordinal);
[Benchmark]
public bool Bestcase_IgnoreCase() =>
s.StartsWith("https://pkgs.dev.azure.com/dnceng/public/pack", StringComparison.OrdinalIgnoreCase);
// Worst case: differs at 1st char:
[Benchmark]
public bool Worstcase() =>
s.StartsWith("Xttps://pkgs.dev.azure.com/dnceng/public/pack", StringComparison.Ordinal);
[Benchmark]
public bool Worstcase_IgnoreCase() =>
s.StartsWith("Xttps://pkgs.dev.azure.com/dnceng/public/pack", StringComparison.OrdinalIgnoreCase);
} |
@MihuBot -arm -dependsOn 108838 |
PTAL @jakobbotsch @dotnet/jit-contrib this improves perf on arm64 (even in the worst case when the first char is different). Seems like makes no sense on x64 judging by benchmarks. |
Do you have a link to the perf numbers on x64? I would expect this to be similar perf on most x64, but likely better on CPUs like e-cores or other scenarios where call overhead is greater |
@EgorBot -amd -intel --envvars DOTNET_JitDisasm:Bestcase_IgnoreCase using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
public class Bench
{
string s = "https://pkgs.dev.azure.com/dnceng/public/packaging/dotnet10/";
[Benchmark]
public bool Bestcase() =>
s.StartsWith("https://pkgs.dev.azure.com/dnceng/public/pack", StringComparison.Ordinal);
[Benchmark]
public bool Bestcase_IgnoreCase() =>
s.StartsWith("https://pkgs.dev.azure.com/dnceng/public/pack", StringComparison.OrdinalIgnoreCase);
// Worst case: differs at 1st char:
[Benchmark]
public bool Worstcase() =>
s.StartsWith("Xttps://pkgs.dev.azure.com/dnceng/public/pack", StringComparison.Ordinal);
[Benchmark]
public bool Worstcase_IgnoreCase() =>
s.StartsWith("Xttps://pkgs.dev.azure.com/dnceng/public/pack", StringComparison.OrdinalIgnoreCase);
} |
@tannergooding you can find x64 numbers here EgorBot/runtime-utils#162, Basically, almost no wins and clear regressions unlike arm64 |
Thanks! That roughly fits my expectations for that hardware. I don't think we have any e-cores to see if there is a contrast for those devices though, unfortunately. I have no concerns with it being merged, just wanted to see some of the numbers since it was called out |
Seems like it's quite beneficial even on large sizes, at least on arm64: