-
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
When calculating xxhash, net7.0 is slower than net6.0 #90090
Comments
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsDescription internal unsafe class Program
{
public static void Main(string[] args)
{
var buffer = Encoding.UTF8.GetBytes("aadwejkadjgb8c27tr874c3/./[}|P{OP&^&$%^^TGERfgea");
var sw = Stopwatch.GetTimestamp();
for (int i = 0; i < 1_000_000; i++)
{
XxHash64.Hash(buffer);
}
Console.WriteLine(new TimeSpan(Stopwatch.GetTimestamp() - sw));
}
} The csproj <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.IO.Hashing" Version="7.0.0" />
</ItemGroup>
</Project> dotnet run -c Release -f net6.0 Result 00:00:00.1590156 dotnet run -c Release -f net7.0 Result 00:00:00.2138358 ConfigurationOS Name: Windows Regression?I don't know. DataNone.
|
The difference between net6.0 and net7.0 is not that big, but net8.0 shows 2x+ regression: Benchmark codeusing System.IO.Hashing;
using System.Text;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<Benchs>();
[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net80)]
public class Benchs
{
private readonly byte[] buffer = Encoding.UTF8.GetBytes("aadwejkadjgb8c27tr874c3/./[}|P{OP&^&$%^^TGERfgea");
[Benchmark]
public byte[] BenchXxhash()
{
return XxHash64.Hash(buffer);
}
}
|
I bet it's #87113 (comment) |
Or it can be PGO actually... cc @AndyAyersMS using System.Diagnostics;
using System.IO.Hashing;
internal class Program
{
public static void Main()
{
byte[] buffer = "aadwejkadjgb8c27tr874c3/./[}|P{OP&^&$%^^TGERfgea"u8.ToArray();
Stopwatch sw = Stopwatch.StartNew();
while (true)
{
sw.Restart();
for (int i = 0; i < 1_000_000; i++)
XxHash64.Hash(buffer);
sw.Stop();
Console.WriteLine(sw.ElapsedMilliseconds);
}
}
} smells like the inliner budget problem - i see BinaryPrimitives.Read* apis non-inlined on hot path |
public static void Main()
{
byte[] buffer = "aadwejkadjgb8c27tr874c3/./[}|P{OP&^&$%^^TGERfgea"u8.ToArray();
for (int i = 0; i < 1_000_000; i++)
XxHash64.Hash(buffer);
}
Note a few |
Description
The csproj
Result 00:00:00.1590156
Result 00:00:00.2138358
Configuration
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win10-x64
Regression?
I don't know.
Data
None.
The text was updated successfully, but these errors were encountered: