runtime: Performance regression in System.ServiceProcess.ServiceController, .Net Core App 2.1
This was found in PowerShell Core6 (https://github.com/PowerShell/PowerShell) while investigating PowerShell cmdlet perf regression. I tracked the perf regression to this .Net type:
System.ServiceProcess.ServiceController
Using this type is approximately 30 times slower when running under .Net CoreApp 2.1
Repro steps:
using System;
using System.ServiceProcess;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
System.Console.WriteLine("Starting loop");
var start = DateTime.Now;
for (var i=0; i<100; i++)
{
var winRMService = new ServiceController("WinRM");
if (winRMService != null)
{
var status = winRMService.Status;
}
}
var end = DateTime.Now;
System.Console.WriteLine("End loop");
System.Console.WriteLine(String.Format("Time in milliseconds = {0}", (end - start).Milliseconds));
System.Console.WriteLine("Press any key to continue");
System.Console.ReadKey();
}
}
}
Results: Under .Net Core App 2.1 Time in milliseconds = 714
Under .Net Full CLR Time in milliseconds = 24
Expected: Use of ServiceController type should have approximately the same performance between each version of .Net.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 20 (13 by maintainers)
I wrote small micro-benchmark to verify it. It proves that on .NET Core given property (
.Status
) is actually 23% faster:dotnet run -c Release -f netcoreapp2.1
@PaulHigin which profiler did you use? Could you share some traces?