Skip to content

PerfCollect diagnoser #2117

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

Merged
merged 26 commits into from
Sep 29, 2022
Merged

PerfCollect diagnoser #2117

merged 26 commits into from
Sep 29, 2022

Conversation

adamsitnik
Copy link
Member

@adamsitnik adamsitnik commented Sep 22, 2022

I am opening the PR to start a discussion. I know I need to write some docs and test it before it gets merged.

image

Must have:

Nice to have:

Please see dotnet/runtime#71786 (comment) for .NET 7 limitations

cc @janvorli

@adamsitnik adamsitnik added this to the v0.13.3 milestone Sep 22, 2022
{
start.EnvironmentVariables["COMPlus_PerfMapEnabled"] = "1";
start.EnvironmentVariables["COMPlus_EnableEventLog"] = "1";
start.EnvironmentVariables["COMPlus_EventSourceFilter"] = EngineEventSource.SourceName;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brianrob if I want to enable all events for given event source, is setting COMPlus_EventSourceFilter enough?

The definition of event source that I care about:

[EventSource(Name = EngineEventSource.SourceName)]
public class EngineEventSource : EventSource
{
public const string SourceName = "BenchmarkDotNet.EngineEventSource";

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that and setting COMPlus_EnableEventLog=1. If you set COMPlus_EventSourceFilter to the EventSource that you want to capture, this will disable all other EventSources from being sent through to LTTng to avoid the cost of emitting all other EventSource events that may not be needed.

@lewing
Copy link
Member

lewing commented Oct 14, 2022

This appears to be breaking the wasm tests now that it has made it into dotnet/performance

@AndyAyersMS
Copy link
Member

I finally got around to trying this out, looks like maybe it does not work with locally built runtimes?

    dotnet run -c Release -f net7.0 -- -filter System.Collections.Sort<IntStruct>.List(Size: 512)  --corerun /home/andy/bugs/r87194/base-rel/corerun --iterationCount 25 -p perf
// Validating benchmarks:
// ***** BenchmarkRunner: Start   *****
// ***** Found 1 benchmark(s) in total *****
// ***** Building 1 exe(s) in Parallel: Start   *****
// start dotnet  restore /p:EnableUnsafeBinaryFormatterSerialization=true /p:UseSharedCompilation=false /p:BuildInParallel=false /m:1 /p:Deterministic=true /p:Optimize=true in /home/andy/repos/performance/artifacts/bin/MicroBenchmarks/Release/net7.0/b3768f1b-a8be-4010-9bb8-f2b99c0cee65
// command took 3.74s and exited with 0
// start dotnet  build -c Release /p:EnableUnsafeBinaryFormatterSerialization=true --no-restore /p:UseSharedCompilation=false /p:BuildInParallel=false /m:1 /p:Deterministic=true /p:Optimize=true in /home/andy/repos/performance/artifacts/bin/MicroBenchmarks/Release/net7.0/b3768f1b-a8be-4010-9bb8-f2b99c0cee65
// command took 5.74s and exited with 0
// start dotnet  publish -c Release /p:EnableUnsafeBinaryFormatterSerialization=true --no-build --no-restore /p:UseSharedCompilation=false /p:BuildInParallel=false /m:1 /p:Deterministic=true /p:Optimize=true --output "/home/andy/repos/performance/artifacts/bin/MicroBenchmarks/Release/net7.0/b3768f1b-a8be-4010-9bb8-f2b99c0cee65/bin/Release/net7.0/publish" in /home/andy/repos/performance/artifacts/bin/MicroBenchmarks/Release/net7.0/b3768f1b-a8be-4010-9bb8-f2b99c0cee65
// command took 2.93s and exited with 0
Copying /home/andy/repos/performance/artifacts/bin/MicroBenchmarks/Release/net7.0/b3768f1b-a8be-4010-9bb8-f2b99c0cee65/bin/Release/net7.0/publish/CommandLine.dll to /home/andy/bugs/r87194/858959aa-3872-429d-882c-44a1bbe34dcc/CommandLine.dll
// ***** Done, took 00:00:39 (39.01 sec)   *****
// Found 1 benchmarks:
//   Sort<IntStruct>.List: Job-PLNYLF(PowerPlanMode=00000000-0000-0000-0000-000000000000, Arguments=/p:EnableUnsafeBinaryFormatterSerialization=true, Toolchain=CoreRun, InvocationCount=5000, IterationCount=25, IterationTime=250.0000 ms, MaxIterationCount=20, MinIterationCount=15, MinWarmupIterationCount=6, UnrollFactor=1, WarmupCount=-1) [Size=512]

// **************************
// Benchmark: Sort<IntStruct>.List: Job-PLNYLF(PowerPlanMode=00000000-0000-0000-0000-000000000000, Arguments=/p:EnableUnsafeBinaryFormatterSerialization=true, Toolchain=CoreRun, InvocationCount=5000, IterationCount=25, IterationTime=250.0000 ms, MaxIterationCount=20, MinIterationCount=15, MinWarmupIterationCount=6, UnrollFactor=1, WarmupCount=-1) [Size=512]
// *** Execute ***
// Launch: 1 / 1
// Execute: /home/andy/bugs/r87194/858959aa-3872-429d-882c-44a1bbe34dcc/corerun b3768f1b-a8be-4010-9bb8-f2b99c0cee65.dll --anonymousPipes 228 229 --benchmarkName "System.Collections.Sort<IntStruct>.List(Size: 512)" --job "PowerPlanMode=00000000-0000-0000-0000-000000000000, Arguments=/p:EnableUnsafeBinaryFormatterSerialization=true, Toolchain=CoreRun, InvocationCount=5000, IterationCount=25, IterationTime=250.0000 ms, MaxIterationCount=20, MinIterationCount=15, MinWarmupIterationCount=6, UnrollFactor=1, WarmupCount=-1" --benchmarkId 0 in /home/andy/repos/performance/artifacts/bin/MicroBenchmarks/Release/net7.0/b3768f1b-a8be-4010-9bb8-f2b99c0cee65/bin/Release/net7.0/publish
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at BenchmarkDotNet.Diagnosers.PerfCollectProfiler.EnsureSymbolsForNativeRuntime(DiagnoserActionParameters parameters)
   at BenchmarkDotNet.Diagnosers.PerfCollectProfiler.StartCollection(DiagnoserActionParameters parameters)
   at BenchmarkDotNet.Diagnosers.PerfCollectProfiler.Handle(HostSignal signal, DiagnoserActionParameters parameters)
   at BenchmarkDotNet.Diagnosers.CompositeDiagnoser.Handle(HostSignal signal, DiagnoserActionParameters parameters)
   at BenchmarkDotNet.Toolchains.DotNetCli.DotNetCliExecutor.Execute(BenchmarkCase benchmarkCase, BenchmarkId benchmarkId, ILogger logger, ArtifactsPaths artifactsPaths, IDiagnoser diagnoser, String executableName, IResolver resolver, Int32 launchIndex)
   at BenchmarkDotNet.Toolchains.DotNetCli.DotNetCliExecutor.Execute(ExecuteParameters executeParameters)
   at BenchmarkDotNet.Running.BenchmarkRunnerClean.RunExecute(ILogger logger, BenchmarkCase benchmarkCase, BenchmarkId benchmarkId, IToolchain toolchain, BuildResult buildResult, IResolver resolver, IDiagnoser diagnoser, Int32 launchIndex)
   at BenchmarkDotNet.Running.BenchmarkRunnerClean.Execute(ILogger logger, BenchmarkCase benchmarkCase, BenchmarkId benchmarkId, IToolchain toolchain, BuildResult buildResult, IResolver resolver)
   at BenchmarkDotNet.Running.BenchmarkRunnerClean.RunCore(BenchmarkCase benchmarkCase, BenchmarkId benchmarkId, ILogger logger, IResolver resolver, BuildResult buildResult)
   at BenchmarkDotNet.Running.BenchmarkRunnerClean.Run(BenchmarkRunInfo benchmarkRunInfo, Dictionary`2 buildResults, IResolver resolver, ILogger logger, List`1 artifactsToCleanup, String resultsFolderPath, String logFilePath, Int32 totalBenchmarkCount, StartedClock& runsChronometer, Int32& benchmarksToRunCount, TaskbarProgress taskbarProgress)
   at BenchmarkDotNet.Running.BenchmarkRunnerClean.Run(BenchmarkRunInfo[] benchmarkRunInfos)
   at BenchmarkDotNet.Running.BenchmarkSwitcher.RunWithDirtyAssemblyResolveHelper(String[] args, IConfig config, Boolean askUserForInput)
   at BenchmarkDotNet.Running.BenchmarkSwitcher.Run(String[] args, IConfig config)
   at MicroBenchmarks.Program.Main(String[] args) in /home/andy/repos/performance/src/benchmarks/micro/Program.cs:line 43

@adamsitnik
Copy link
Member Author

@AndyAyersMS could you please log an issue? I suspect that we should just skip EnsureSymbolsForNativeRuntime for corerun toolchain

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

Successfully merging this pull request may close these issues.

4 participants