-
Couldn't load subscription status.
- Fork 5.2k
CI test #99871
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
CI test #99871
Conversation
|
@EgorBot -arm64 -amd -intel using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Runtime.InteropServices;
BenchmarkRunner.Run<Utf8Bench>(args: args);
public unsafe class Utf8Bench
{
byte* _ptr1 = null;
byte* _ptr2 = null;
[GlobalSetup]
public void GlobalSetup()
{
_ptr1 = (byte*)NativeMemory.AlignedAlloc(300 * 1024 * 1024, 64) + 8;
_ptr2 = (byte*)NativeMemory.AlignedAlloc(300 * 1024 * 1024, 64) + 8;
}
[GlobalCleanup]
public void GlobalCleanup()
{
NativeMemory.Free(_ptr1);
NativeMemory.Free(_ptr2);
}
public static IEnumerable<long> Sizes()
{
yield return 1_000;
yield return 10_000;
yield return 100_000;
yield return 1_000_000;
yield return 10_000_000;
yield return 100_000_000;
}
[Benchmark]
[ArgumentsSource(nameof(Sizes))]
public void Managed(long size) => Buffer.MemoryCopy(_ptr1, _ptr2, size, size);
[Benchmark]
[ArgumentsSource(nameof(Sizes))]
public void Native(long size) => memcpy(_ptr1, _ptr2, (nuint)size);
[DllImport("libc")]
static extern nuint memcpy(byte* dest, byte* src, nuint size);
} |
|
@EgorBot -intel using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Runtime.InteropServices;
BenchmarkRunner.Run<Utf8Bench>(args: args);
public unsafe class Utf8Bench
{
byte* _ptr1 = null;
byte* _ptr2 = null;
[GlobalSetup]
public void GlobalSetup()
{
_ptr1 = (byte*)NativeMemory.AlignedAlloc(300 * 1024 * 1024, 64);
_ptr2 = (byte*)NativeMemory.AlignedAlloc(300 * 1024 * 1024, 64);
}
[GlobalCleanup]
public void GlobalCleanup()
{
NativeMemory.Free(_ptr1);
NativeMemory.Free(_ptr2);
}
public static IEnumerable<long> Sizes()
{
yield return 100_000;
}
[Benchmark]
[ArgumentsSource(nameof(Sizes))]
public void Managed(long size) => Buffer.MemoryCopy(_ptr1, _ptr2, size, size);
} |
4 similar comments
|
@EgorBot -intel using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Runtime.InteropServices;
BenchmarkRunner.Run<Utf8Bench>(args: args);
public unsafe class Utf8Bench
{
byte* _ptr1 = null;
byte* _ptr2 = null;
[GlobalSetup]
public void GlobalSetup()
{
_ptr1 = (byte*)NativeMemory.AlignedAlloc(300 * 1024 * 1024, 64);
_ptr2 = (byte*)NativeMemory.AlignedAlloc(300 * 1024 * 1024, 64);
}
[GlobalCleanup]
public void GlobalCleanup()
{
NativeMemory.Free(_ptr1);
NativeMemory.Free(_ptr2);
}
public static IEnumerable<long> Sizes()
{
yield return 100_000;
}
[Benchmark]
[ArgumentsSource(nameof(Sizes))]
public void Managed(long size) => Buffer.MemoryCopy(_ptr1, _ptr2, size, size);
} |
|
@EgorBot -intel using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Runtime.InteropServices;
BenchmarkRunner.Run<Utf8Bench>(args: args);
public unsafe class Utf8Bench
{
byte* _ptr1 = null;
byte* _ptr2 = null;
[GlobalSetup]
public void GlobalSetup()
{
_ptr1 = (byte*)NativeMemory.AlignedAlloc(300 * 1024 * 1024, 64);
_ptr2 = (byte*)NativeMemory.AlignedAlloc(300 * 1024 * 1024, 64);
}
[GlobalCleanup]
public void GlobalCleanup()
{
NativeMemory.Free(_ptr1);
NativeMemory.Free(_ptr2);
}
public static IEnumerable<long> Sizes()
{
yield return 100_000;
}
[Benchmark]
[ArgumentsSource(nameof(Sizes))]
public void Managed(long size) => Buffer.MemoryCopy(_ptr1, _ptr2, size, size);
} |
|
@EgorBot -intel using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Runtime.InteropServices;
BenchmarkRunner.Run<Utf8Bench>(args: args);
public unsafe class Utf8Bench
{
byte* _ptr1 = null;
byte* _ptr2 = null;
[GlobalSetup]
public void GlobalSetup()
{
_ptr1 = (byte*)NativeMemory.AlignedAlloc(300 * 1024 * 1024, 64);
_ptr2 = (byte*)NativeMemory.AlignedAlloc(300 * 1024 * 1024, 64);
}
[GlobalCleanup]
public void GlobalCleanup()
{
NativeMemory.Free(_ptr1);
NativeMemory.Free(_ptr2);
}
public static IEnumerable<long> Sizes()
{
yield return 100_000;
}
[Benchmark]
[ArgumentsSource(nameof(Sizes))]
public void Managed(long size) => Buffer.MemoryCopy(_ptr1, _ptr2, size, size);
} |
|
@EgorBot -intel using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Runtime.InteropServices;
BenchmarkRunner.Run<Utf8Bench>(args: args);
public unsafe class Utf8Bench
{
byte* _ptr1 = null;
byte* _ptr2 = null;
[GlobalSetup]
public void GlobalSetup()
{
_ptr1 = (byte*)NativeMemory.AlignedAlloc(300 * 1024 * 1024, 64);
_ptr2 = (byte*)NativeMemory.AlignedAlloc(300 * 1024 * 1024, 64);
}
[GlobalCleanup]
public void GlobalCleanup()
{
NativeMemory.Free(_ptr1);
NativeMemory.Free(_ptr2);
}
public static IEnumerable<long> Sizes()
{
yield return 100_000;
}
[Benchmark]
[ArgumentsSource(nameof(Sizes))]
public void Managed(long size) => Buffer.MemoryCopy(_ptr1, _ptr2, size, size);
} |
❌ Benchmark failed on Intel |
|
@EgorBot -intel using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Runtime.InteropServices;
BenchmarkRunner.Run<Utf8Bench>(args: args);
public unsafe class Utf8Bench
{
byte* _ptr1 = null;
byte* _ptr2 = null;
[GlobalSetup]
public void GlobalSetup()
{
_ptr1 = (byte*)NativeMemory.AlignedAlloc(300 * 1024 * 1024, 64);
_ptr2 = (byte*)NativeMemory.AlignedAlloc(300 * 1024 * 1024, 64);
}
[GlobalCleanup]
public void GlobalCleanup()
{
NativeMemory.Free(_ptr1);
NativeMemory.Free(_ptr2);
}
public static IEnumerable<long> Sizes()
{
yield return 100_000;
}
[Benchmark]
[ArgumentsSource(nameof(Sizes))]
public void Managed(long size) => Buffer.MemoryCopy(_ptr1, _ptr2, size, size);
} |
❌ Benchmark failed on Intel |
|
@EgorBot -intel using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Runtime.InteropServices;
BenchmarkRunner.Run<Utf8Bench>(args: args);
public unsafe class Utf8Bench
{
byte* _ptr1 = null;
byte* _ptr2 = null;
[GlobalSetup]
public void GlobalSetup()
{
_ptr1 = (byte*)NativeMemory.AlignedAlloc(300 * 1024 * 1024, 64);
_ptr2 = (byte*)NativeMemory.AlignedAlloc(300 * 1024 * 1024, 64);
}
[GlobalCleanup]
public void GlobalCleanup()
{
NativeMemory.Free(_ptr1);
NativeMemory.Free(_ptr2);
}
public static IEnumerable<long> Sizes()
{
yield return 100_000;
}
[Benchmark]
[ArgumentsSource(nameof(Sizes))]
public void Managed(long size) => Buffer.MemoryCopy(_ptr1, _ptr2, size, size);
} |
Benchmark results on Intel
|
|
@EgorBot -intel using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<MyBench>(args: args); // args must be forwarded to BDN!
public class MyBench
{
string _str = "dotnet/RUNTIME";
[Benchmark]
public bool Test() =>
// JIT is expected to unroll this with SIMD:
_str.Equals("dotnet/runtime", StringComparison.OrdinalIgnoreCase);
} |
|
@EgorBot -intel using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<MyBench>(args: args); // args must be forwarded to BDN!
public class MyBench
{
string _str = "dotnet/RUNTIME";
[Benchmark]
public bool Test() =>
// JIT is expected to unroll this with SIMD:
_str.Equals("dotnet/runtime", StringComparison.OrdinalIgnoreCase);
} |
Benchmark results on Intel
|
|
@EgorBot -arm64 -profile using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<Bench>(args: args);
public class Bench
{
// struct in heap
MyStruct MS = new();
[Benchmark]
public void CheckedWB_InHeap()
{
string str = new string('x', 1);
for (long i = 0; i < 200000000; i++)
CheckedWriteBarrier(ref MS, str);
}
[MethodImpl(MethodImplOptions.NoInlining)]
void CheckedWriteBarrier(ref MyStruct ms, string str) => ms.Str = str;
}
public record struct MyStruct(string Str);
internal class Foo
{
public volatile Foo x;
} |
Benchmark results on Arm64
Flame graphs: Main vs PR 🔥 For clean |
No description provided.