Open performanceautofiler[bot] opened 2 months ago
Transfering this to start investigation into extreme increase in noisiness around July 19th. This noisiness increase seems to only be on the Viper machines and affects both Linux and Windows.
@AndyAyersMS @EgorBo
@EgorBot -amd -commit 39968e7 vs previous --filter System.Numerics.Tests.Perf_BitOperations.TrailingZeroCount_ulong
@EgorBot -amd -commit 39968e7 vs previous --filter System.Numerics.Tests.Perf_BitOperations.TrailingZeroCount_ulong
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch See info in area-owners.md if you want to be subscribed.
@EgorBot -amd -commit 39968e7 vs previous -profiler
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Numerics;
using System.Runtime.CompilerServices;
public class Perf_BitOperations
{
static T[] Array<T>(int count, int? seed = null)
{
var result = new T[count];
var random = new Random(42);
if (typeof(T) == typeof(byte) || typeof(T) == typeof(sbyte))
random.NextBytes(Unsafe.As<byte[]>(result));
else
for (int i = 0; i < result.Length; i++)
result[i] = GenerateValue<T>(random);
return result;
}
static T GenerateValue<T>(Random random)
{
if (typeof(T) == typeof(uint))
return (T)(object)(uint)random.Next();
if (typeof(T) == typeof(ulong))
return (T)(object)(ulong)random.Next();
throw new NotImplementedException();
}
static uint[] input_uint = Array<uint>(1000);
static ulong[] input_ulong = Array<ulong>(1000);
[Benchmark]
public int TrailingZeroCount_ulong()
{
int sum = 0;
ulong[] input = input_ulong;
for (int i = 0; i < input.Length; i++)
{
sum += BitOperations.TrailingZeroCount(input[i]);
}
return sum;
}
}
@EgorBot -amd -commit 72f9ee0d26c23b3c58ec5af8aeea316095761646 vs 767e4165641583c73918168a920a10513000572c -profiler --envvars DOTNET_JitDisasm:TrailingZeroCount_ulong
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Numerics;
using System.Runtime.CompilerServices;
public class Perf_BitOperations
{
static T[] Array<T>(int count, int? seed = null)
{
var result = new T[count];
var random = new Random(42);
if (typeof(T) == typeof(byte) || typeof(T) == typeof(sbyte))
random.NextBytes(Unsafe.As<byte[]>(result));
else
for (int i = 0; i < result.Length; i++)
result[i] = GenerateValue<T>(random);
return result;
}
static T GenerateValue<T>(Random random)
{
if (typeof(T) == typeof(uint))
return (T)(object)(uint)random.Next();
if (typeof(T) == typeof(ulong))
return (T)(object)(ulong)random.Next();
throw new NotImplementedException();
}
static uint[] input_uint = Array<uint>(1000);
static ulong[] input_ulong = Array<ulong>(1000);
[Benchmark]
public int TrailingZeroCount_ulong()
{
int sum = 0;
ulong[] input = input_ulong;
for (int i = 0; i < input.Length; i++)
{
sum += BitOperations.TrailingZeroCount(input[i]);
}
return sum;
}
}
@EgorBot -amd -commit 72f9ee0d26c23b3c58ec5af8aeea316095761646 vs previous -profiler --envvars DOTNET_JitDisasm:TrailingZeroCount_ulong
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Numerics;
using System.Runtime.CompilerServices;
public class Perf_BitOperations
{
static T[] Array<T>(int count, int? seed = null)
{
var result = new T[count];
var random = new Random(42);
if (typeof(T) == typeof(byte) || typeof(T) == typeof(sbyte))
random.NextBytes(Unsafe.As<byte[]>(result));
else
for (int i = 0; i < result.Length; i++)
result[i] = GenerateValue<T>(random);
return result;
}
static T GenerateValue<T>(Random random)
{
if (typeof(T) == typeof(uint))
return (T)(object)(uint)random.Next();
if (typeof(T) == typeof(ulong))
return (T)(object)(ulong)random.Next();
throw new NotImplementedException();
}
static uint[] input_uint = Array<uint>(1000);
static ulong[] input_ulong = Array<ulong>(1000);
[Benchmark]
public int TrailingZeroCount_ulong()
{
int sum = 0;
ulong[] input = input_ulong;
for (int i = 0; i < input.Length; i++)
{
sum += BitOperations.TrailingZeroCount(input[i]);
}
return sum;
}
}
@EgorBot -amd -awsamd -commit 72f9ee0d26c23b3c58ec5af8aeea316095761646 vs previous -profiler --envvars DOTNET_JitDisasm:TrailingZeroCount_ulong
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Numerics;
using System.Runtime.CompilerServices;
public class Perf_BitOperations
{
static T[] Array<T>(int count, int? seed = null)
{
var result = new T[count];
var random = new Random(42);
if (typeof(T) == typeof(byte) || typeof(T) == typeof(sbyte))
random.NextBytes(Unsafe.As<byte[]>(result));
else
for (int i = 0; i < result.Length; i++)
result[i] = GenerateValue<T>(random);
return result;
}
static T GenerateValue<T>(Random random)
{
if (typeof(T) == typeof(uint))
return (T)(object)(uint)random.Next();
if (typeof(T) == typeof(ulong))
return (T)(object)(ulong)random.Next();
throw new NotImplementedException();
}
static uint[] input_uint = Array<uint>(1000);
static ulong[] input_ulong = Array<ulong>(1000);
[Benchmark]
public int TrailingZeroCount_ulong()
{
int sum = 0;
ulong[] input = input_ulong;
for (int i = 0; i < input.Length; i++)
{
sum += BitOperations.TrailingZeroCount(input[i]);
}
return sum;
}
}
@EgorBot -awsamd -commit 72f9ee0d26c23b3c58ec5af8aeea316095761646 vs 767e4165641583c73918168a920a10513000572c -profiler --envvars DOTNET_JitDisasm:TrailingZeroCount_ulong
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Numerics;
using System.Runtime.CompilerServices;
public class Perf_BitOperations
{
static T[] Array<T>(int count, int? seed = null)
{
var result = new T[count];
var random = new Random(42);
if (typeof(T) == typeof(byte) || typeof(T) == typeof(sbyte))
random.NextBytes(Unsafe.As<byte[]>(result));
else
for (int i = 0; i < result.Length; i++)
result[i] = GenerateValue<T>(random);
return result;
}
static T GenerateValue<T>(Random random)
{
if (typeof(T) == typeof(uint))
return (T)(object)(uint)random.Next();
if (typeof(T) == typeof(ulong))
return (T)(object)(ulong)random.Next();
throw new NotImplementedException();
}
static uint[] input_uint = Array<uint>(1000);
static ulong[] input_ulong = Array<ulong>(1000);
[Benchmark]
public int TrailingZeroCount_ulong()
{
int sum = 0;
ulong[] input = input_ulong;
for (int i = 0; i < input.Length; i++)
{
sum += BitOperations.TrailingZeroCount(input[i]);
}
return sum;
}
}
I think it is still interesting to investigate the source of randomness here, but looks like it is just one machine (I was not able to reproduce the same noise on AWS AMD machine) and one benchmark, moving to 10.0
Run Information
Regressions in System.Numerics.Tests.Perf_BitOperations
Test Report
Repro
General Docs link: https://github.com/dotnet/performance/blob/main/docs/benchmarking-workflow-dotnet-runtime.md