Skip to content
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

The EventPipeProfiler cross-platform profiler #1321

Merged
merged 14 commits into from
Mar 3, 2020

Conversation

WojciechNagorski
Copy link
Contributor

@WojciechNagorski WojciechNagorski commented Nov 27, 2019

Changes for #1315

Currently, I use a local build of Microsoft.Diagnostics.NETCore.Client from dotnet/diagnostics#617. This library support only .Net Core 2.1 so I decided that I create a new library BenchmarkDotNet.Diagnostics.NETCore that contains EventPipeProfiler.

(I don't like the name "NETCore" but I wanted to do it like in Microsoft.Diagnostics.NETCore.Client )

You can run this profiler via command line:

dotnet BenchmarkDotNet.Samples.dll --filter *Algo_Md5VsSha256.Md5* -p EventPipe -j Short

image

Example trace file.zip

image

@adamsitnik
Copy link
Member

I've tested the proposed EventPipeProfiler and it works fine. Great work @WojciechNagorski !

I've sent dotnet/diagnostics#700 in order to add .NET Standard 2.0 support to Microsoft.Diagnostics.NETCore.Client so we could just add this diagnoser to existing package without adding .NET Core target.

@WojciechNagorski
Copy link
Contributor Author

@adamsitnik Thanks. I'm going to finish this task this week.

@adamsitnik
Copy link
Member

dotnet/diagnostics#700 got merged and it targets .NET Standard 2.0 now, so IMHO we can add this dependency to main BenchmarkDotNet project and just add the new profiler plugin there

@WojciechNagorski
Copy link
Contributor Author

@adamsitnik Great. Today I will move EventPipeProfiler to the BenchmarkDotNet project.

@WojciechNagorski
Copy link
Contributor Author

I've pushed the updated version of EventPipeProfiler. It is still WIP, I need to test all cases.

Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

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

@WojciechNagorski thanks for another great PR!

Please address my comments before we merge it. Thanks!

# Visual Studio 15
VisualStudioVersion = 15.0.27130.2027
# Visual Studio Version 16
VisualStudioVersion = 16.0.29102.190
Copy link
Member

Choose a reason for hiding this comment

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

please revert all the changes to solution file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will revert the version of Visual Studio. But I think that guilds should be changed, dotnet/project-system#3079 (comment)
and
dotnet/project-system#2863
What do you think?

src/BenchmarkDotNet/Diagnosers/DiagnosersLoader.cs Outdated Show resolved Hide resolved
src/BenchmarkDotNet/Diagnosers/EventPipeProfiler.cs Outdated Show resolved Hide resolved
src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs Outdated Show resolved Hide resolved
src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs Outdated Show resolved Hide resolved
src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs Outdated Show resolved Hide resolved
@WojciechNagorski WojciechNagorski changed the title [WIP] EventPipeProfiler The EventPipeProfiler cross-platform profiler Dec 18, 2019
@WojciechNagorski
Copy link
Contributor Author

@adamsitnik I made the changes you asked for. I have questions for two topics.

@WojciechNagorski
Copy link
Contributor Author

@adamsitnik ping

adamsitnik
adamsitnik previously approved these changes Mar 3, 2020
Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

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

Looks great to me, thank you @WojciechNagorski !

Please let me know if you have some time to address my feedback today. If not, I am going to merge it as it is and send a minor improvement PR.

Once again big thanks!

src/BenchmarkDotNet/BenchmarkDotNet.csproj Show resolved Hide resolved
src/BenchmarkDotNet/Diagnosers/EventPipeProfileMapper.cs Outdated Show resolved Hide resolved
{
CpuSampling,
GcVerbose,
GcCollect
Copy link
Member

Choose a reason for hiding this comment

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

it would be great to add Jit to this list with inlining and tail call info enabled

Path.GetDirectoryName(fileName).CreateIfNotExists();
benchmarkToTraceFile[parameters.BenchmarkCase] = fileName;

collectingTask = new Task(() =>
Copy link
Member

Choose a reason for hiding this comment

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

nit: we have quite a deep nesting here. in a perfect world, we would move this logic to a separate method and avoid closure capture


public string ShortName => "EventPipe";

private void ConvertToSpeedscope(BenchmarkCase benchmarkCase, string traceFilePath)
Copy link
Member

Choose a reason for hiding this comment

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

this class is responsible for profiling using event pipe (EventPipeProfiler) could you please move everything that is related to exporting to speedscope to a dedicated type?

}
}

// Method copied from https://github.com/dotnet/diagnostics/blob/2c23d3265dd8f642a8d6cf4bb8a135a5ff8b00c2/src/Tools/dotnet-trace/TraceFileFormatConverter.cs#L64
Copy link
Member

Choose a reason for hiding this comment

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

thanks for adding the comment!

public class EngineEventSource : EventSource
{
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.

it looks like there is no need to extract const if it's used only in once place. Could you please revert this change?

src/BenchmarkDotNet/Helpers/ArtifactFileNameHelper.cs Outdated Show resolved Hide resolved
Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

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

It looks like I need to approve it again after pushing GH suggestions...

@adamsitnik adamsitnik merged commit c648ff9 into dotnet:master Mar 3, 2020
@AndreyAkinshin AndreyAkinshin added this to the v0.12.1 milestone Mar 3, 2020
@WojciechNagorski
Copy link
Contributor Author

@adamsitnik I will try to fix it now.

@adamsitnik
Copy link
Member

I will try to fix it now.

@WojciechNagorski don't worry about this, I am going to send a small PR with the improvements

@WojciechNagorski
Copy link
Contributor Author

@adamsitnik Ok, so I won't change anything. There you can find what I've done so far: #1382

@WojciechNagorski WojciechNagorski deleted the task-EventPipeProfiler branch March 3, 2020 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants