runtime: Performance regression on Guid.Equals
When it’s equal .NET Core is faster but when not, which happens probably more often, .NET Framework is faster.
BenchmarkDotNet=v0.11.5, OS=Windows 10.0.18362
Intel Core i7-4960X CPU 3.60GHz (Haswell), 1 CPU, 12 logical and 6 physical cores
.NET Core SDK=3.0.100-preview7-012593
[Host] : .NET Core 3.0.0-preview7-27824-03 (CoreCLR 4.700.19.32302, CoreFX 4.700.19.32001), 64bit RyuJIT
Clr : .NET Framework 4.7.2 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.8.3815.0
Core : .NET Core 3.0.0-preview7-27824-03 (CoreCLR 4.700.19.32302, CoreFX 4.700.19.32001), 64bit RyuJIT
Method | Job | Runtime | Mean | Error | StdDev |
---|---|---|---|---|---|
NoMatchGuid | Clr | Clr | 1.780 ns | 0.0016 ns | 0.0012 ns |
NoMatchGuid | Core | Core | 2.279 ns | 0.0010 ns | 0.0008 ns |
[ClrJob]
[CoreJob]
[RPlotExporter]
public class GuidTest
{
static byte[] FixedGUI = new byte[16] { 0x1, 0x1, 0x1, 0x2, 0x1, 0x1, 0x1, 0x2, 0x1, 0x1, 0x1, 0x2, 0x1, 0x1, 0x1, 0x2 };
static byte[] FixedGUITwo = new byte[16] { 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5 };
Guid OneGuid = new Guid(FixedGUI);
Guid TwoGuid = new Guid(FixedGUITwo);
[Benchmark]
public bool NoMatchGuid() => OneGuid.Equals(TwoGuid);
}
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 23 (19 by maintainers)
Codegen for
Guid.Equals
is the same in 2.2 and 3.0 (note this method is normally prejitted; in 3.0 the tiered version is more or less the same as the prejitted one). I don’t see any regression locally.So I’m still thinking the measured differences are some kind of artifact in the interaction of the benchmarking with HW.
Suggest we close this and keep an eye on the performance history of dotnet/performance#630, and maybe update that test also try first byte diff cases?
A difference in the last byte of the GUID won’t ever show anything interesting because it results in all
Equals
code being run and there’s very little chance that the huge .NET FX version will be anything other than slow. The interesting part is when the difference is in the firstint
of the GUID, that will result into an early out and then both .NET FX and .NET Core should have similar speed.