Skip to content
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

EgorBot for EgorBo in #107437 #80

Open
EgorBot opened this issue Sep 6, 2024 · 3 comments
Open

EgorBot for EgorBo in #107437 #80

EgorBot opened this issue Sep 6, 2024 · 3 comments

Comments

@EgorBot
Copy link
Owner

EgorBot commented Sep 6, 2024

Processing dotnet/runtime#107437 (comment) command:

Command

-arm64 -intel

using BenchmarkDotNet.Attributes;
using System;
using System.Runtime.CompilerServices;

public class Proga
{
    static object[] test1 = [null, null, null];
    static object[] test2 = [null, null, null];
    static object val = null;

    [Benchmark]
    public void StelemRef()
    {
        test1[0] = val;
        test1[1] = val;
        test1[2] = val;
    }

    [Benchmark]
    public void BulkCopy_heap()
    {
        test1.AsSpan().CopyTo(test2);
    }

    [Benchmark]
    public void BulkCopy_stack()
    {
        MyStruct ms = default;
        Copy(ref ms, default);
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    static void Copy(ref MyStruct dst, MyStruct src) => dst = src;

    public record struct MyStruct(object o1, object o2, object o3, object o4);
}

(EgorBot will reply in this issue)

@EgorBot
Copy link
Owner Author

EgorBot commented Sep 6, 2024

Benchmark results on Intel

BenchmarkDotNet v0.14.0, Ubuntu 22.04.4 LTS (Jammy Jellyfish)
Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores
  Job-VMAGSR : .NET 10.0.0 (42.42.42.42424), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
  Job-CTTJLC : .NET 10.0.0 (42.42.42.42424), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
Method Toolchain Mean Error Ratio
StelemRef Main 5.237 ns 0.0007 ns 1.00
StelemRef PR 5.302 ns 0.0005 ns 1.01
BulkCopy_heap Main 8.147 ns 0.0233 ns 1.00
BulkCopy_heap PR 8.170 ns 0.0310 ns 1.00
BulkCopy_stack Main 8.439 ns 0.0109 ns 1.00
BulkCopy_stack PR 8.578 ns 0.0201 ns 1.02

BDN_Artifacts.zip

@EgorBot
Copy link
Owner Author

EgorBot commented Sep 6, 2024

cc @EgorBo (logs)

@EgorBo
Copy link

EgorBo commented Sep 6, 2024

@EgorBot -arm64 -pr 107437

using BenchmarkDotNet.Attributes;
using System;
using System.Runtime.CompilerServices;

public class Proga
{
    static object[] test1 = [null, null, null];
    static object[] test2 = [null, null, null];
    static object val = null;

    [Benchmark]
    public void StelemRef()
    {
        test1[0] = val;
        test1[1] = val;
        test1[2] = val;
    }

    [Benchmark]
    public void BulkCopy_heap()
    {
        test1.AsSpan().CopyTo(test2);
    }

    [Benchmark]
    public void BulkCopy_stack()
    {
        MyStruct ms = default;
        Copy(ref ms, default);
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    static void Copy(ref MyStruct dst, MyStruct src) => dst = src;

    public record struct MyStruct(object o1, object o2, object o3, object o4);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants