EgorBot / runtime-utils

MIT License
0 stars 1 forks source link

EgorBot for EgorBo in #109428 #144

Closed EgorBot closed 3 weeks ago

EgorBot commented 3 weeks ago

Processing https://github.com/dotnet/runtime/pull/109428#issuecomment-2452357005 command:

Command -arm64 -profiler ```cs using BenchmarkDotNet.Attributes; public class Bencha { static object obj = new MyClass(); [Benchmark] public void Bench() { if (obj is MyClass myClass1) myClass1.DoWork(); if (obj is MyClass myClass2) myClass2.DoWork(); if (obj is MyClass myClass3) myClass3.DoWork(); if (obj is MyClass myClass4) myClass4.DoWork(); if (obj is MyClass myClass5) myClass5.DoWork(); if (obj is MyClass myClass6) myClass6.DoWork(); } } public class MyClass { public virtual void DoWork() {} } ```

(EgorBot will reply in this issue)

EgorBot commented 3 weeks ago

cc @EgorBo

EgorBo commented 3 weeks ago

@EgorBot -help

EgorBot commented 3 weeks ago

EgorBot manual

Usage: @EgorBot [-%targets%] [other EgorBot args] [raw args for BDN] `C# snippet surrounded with triple ticks`
-%target%:       Example: "-arm" or "-intel -arm" or "-windows_x64 -linux_aws_genoa"

                 NOTE: target can be prefixed with the OS:
                  -linux_*
                  -windows_*              (x64 only atm)
                  -macos_*                (temporarily disabled)

                 Full list of targets (idiomatic names):
                  -azure_ampere           (temporarily disabled)
                  -azure_cobalt100        (temporarily disabled)
                  -azure_milano           (temporarily disabled)
                  -azure_icelake          (temporarily disabled)
                  -aws_sapphirelake
                  -aws_icelake
                  -aws_genoa
                  -aws_milano
                  -aws_m1                 (temporarily disabled)
                  -aws_m1ultra            (temporarily disabled)
                  -aws_m2                 (temporarily disabled)
                  -aws_m2pro              (temporarily disabled)

                  short aliases:
                  -arm   = -azure_ampere  (temporarily changed to -aws_graviton4)
                  -intel = -azure_icelake (temporarily changed to -aws_sapphirelake)
                  -amd   = -azure_milano  (temporarily changed to -aws_genoa)

-profiler:       Use 'perf record' to collect a flamegraph/hot asm.

-perf_events     Exact events to collect with 'perf', e.g. -perf_events ld_align_lat
                 (events are target-specific, you can find the list of the supported events in BDN_Artifacts.zip
                 when you run a benchmark with -profiler arg).

-commit:         E.g. '-commit 72ea87f vs 380898a' or just '-commit 72ea87f'
                 Runs the benchmark on the specified commit(s) (PR is ignored)

-mono:           Use Mono runtime instead of CoreCLR for all targets. Should be possible to use
                 Mono interp too (LLVM is not supported yet).
                 Mono doesn't support -profiler (at least JIT)
                 To use mono-interp, use BDN args, e.g. --envvars MONO_ENV_OPTIONS:"--interpreter"

-nonativepgo:    Disable native PGO (Build with /p:NoPgoOptimize=true)

-pr %num%:       Run for changes in a specific PR. If bot is invoked from a PR - it takes changes
                 from that PR implicitly.

-[args for BDN]: Args directly passed to BDN e.g. '--disasm', see
                 https://github.com/dotnet/BenchmarkDotNet/blob/master/docs/articles/guides/console-args.md

NOTE: BenchmarkRunner.Run or BenchmarkSwitcher.From* can be omitted (snippet without an entrypoint) Although, if they're presented then Program's args must be be forwarded to Run(args: args)

NOTE: Avoid [DisassemblyDiagnoser] - it causes crashes on Linux, better use --envvars DOTNET_JitDisasm:MethodName

Usage example: link

EgorBot commented 3 weeks ago

cc @EgorBo

EgorBo commented 3 weeks ago

@EgorBot -win_arm -pr 109466

using BenchmarkDotNet.Attributes;

public class C
{
    private static readonly int[] _perm = [1, 2, 3, 4];

    private int Index = 1;

    [Benchmark]
    public int Hash()
    {
        int index = Index;
        return _perm[index & (_perm.Length - 1)];
    }
}
EgorBot commented 3 weeks ago

AwsGraviton4 can't be used with Windows2022. See:

Targets:             OSes:

azure_ampere         linux
azure_milano         linux
azure_icelake        linux
azure_cobalt100      linux
azure_genoa          linux
aws_m1               macos
aws_m1ultra          macos
aws_m2               macos
aws_m2pro            macos
aws_macx86           macos
aws_sapphirelake     linux, windows
aws_icelake          linux, windows
aws_genoa            linux, windows
aws_milano           linux, windows
EgorBot commented 3 weeks ago

cc @EgorBo

EgorBo commented 3 weeks ago

@EgorBot -win_intel -amd -pr 109466

using BenchmarkDotNet.Attributes;

public class C
{
    private static readonly int[] _perm = [1, 2, 3, 4];

    private int Index = 1;

    [Benchmark]
    public int Hash()
    {
        int index = Index;
        return _perm[index & (_perm.Length - 1)];
    }
}
EgorBot commented 3 weeks ago

Benchmark results on windows-sapphirelake

BenchmarkDotNet v0.14.0, Windows 10 (10.0.20348.2762)
Intel Xeon Platinum 8488C, 1 CPU, 16 logical and 8 physical cores
  Job-RHQJNR : .NET 10.0.0 (42.42.42.42424), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
  Job-MXTMRG : .NET 10.0.0 (42.42.42.42424), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
Method Job Toolchain Mean Error Ratio
Hash Job-RHQJNR \core_root_base\corerun.exe 0.0251 ns 0.0382 ns 46.258
Hash Job-MXTMRG \core_root_diff\corerun.exe 0.0000 ns 0.0000 ns 0.000

BDN_Artifacts.zip

EgorBot commented 3 weeks ago

cc @EgorBo (logs)

EgorBot commented 3 weeks ago

Benchmark results on windows-genoa

BenchmarkDotNet v0.14.0, Windows 10 (10.0.20348.2762)
AMD EPYC 9R14, 1 CPU, 16 logical and 16 physical cores
  Job-YXVSHO : .NET 10.0.0 (42.42.42.42424), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
  Job-MIKZXI : .NET 10.0.0 (42.42.42.42424), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
Method Job Toolchain Mean Error Ratio
Hash Job-YXVSHO \core_root_base\corerun.exe 0.2979 ns 0.0185 ns 1.00
Hash Job-MIKZXI \core_root_diff\corerun.exe 0.0088 ns 0.0116 ns 0.03

BDN_Artifacts.zip

EgorBot commented 3 weeks ago

cc @EgorBo (logs)