-
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
PGO: Profile isinst/castclass #65460
Conversation
Tagging subscribers to this area: @JulieLeeMSFT Issue DetailsThis PR adds class probes for some castclass/isinst operations in order to then optimize them in Tier1. I didn't push the change to utilize the PGO for cast/isinst because I want this to be merged first, then flow into our static pgo infrastructure (where I'll enable this flag) and collect isinst/castclass for Simple benchmark with the 2nd change (PGO is enabled): using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
public class Program2 : Program {}
public class Program
{
public static void Main(string[] args)
{
BenchmarkSwitcher
.FromAssembly(typeof(Program).Assembly)
.Run(args);
}
public object[] testData;
[GlobalSetup]
public void Setup()
{
testData = new object[1024];
for (int i = 0; i < testData.Length; i++)
testData[i] = new Program2();
}
[Benchmark]
public int CountPrograms()
{
var array = testData;
int count = 0;
for (int i = 0; i < array.Length; i++)
{
if (array[i] is Program)
count++;
}
return count;
}
[Benchmark]
public void CastPrograms()
{
var array = testData;
for (int i = 0; i < array.Length; i++)
Consume((Program)array[i]);
}
[MethodImpl(MethodImplOptions.NoInlining)]
static void Consume(Program p) {}
}
|
/azp list |
This comment was marked as resolved.
This comment was marked as resolved.
/azp run runtime-coreclr pgo, runtime-coreclr libraries-pgo |
Azure Pipelines successfully started running 2 pipeline(s). |
@AndyAyersMS @jakobbotsch PTAL |
Co-authored-by: Andy Ayers <andya@microsoft.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
One minor suggestion.
This PR adds class probes for some castclass/isinst operations in order to then optimize them in Tier1.
These probes are only supposed to be run for static PGO since they add some overhead for the dynamic one and we want to avoid it, while for the static one we can afford some overhead for a training session.
I didn't push the change to utilize the PGO for cast/isinst because I want this to be merged first, then flow into our static pgo infrastructure (where I'll enable this flag) and collect isinst/castclass for
StandardOptimizationData.mibc
. Then, I'll merge the second change and it will allow me to catch improvements properly for dotnet/performance.Simple benchmark with the 2nd change (PGO is enabled):