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

[dotnet trace] Add Chromium Trace Event file format to list of supported formats #894

Merged
merged 5 commits into from
Mar 11, 2020

Conversation

adamsitnik
Copy link
Member

@adamsitnik adamsitnik commented Mar 10, 2020

This is a continuation of microsoft/perfview#1113

The only thing I was not sure was whether we should compress the file by default or not. There are two ways of opening the trace file in chromium browsers and only one supports compressed files:

  • by using chrome://tracing or edge://tracing/ - it supports compressed files

obraz

  • by using DevTools (F12 in chromium based formats) - it does not support compressed files and IMHO has better visualization capabilities than tracing view

obraz

I am open to suggestions and changing it to always compress the file. Or perhaps in the future we should add an extra argument to the convert command that would control the compression?

The CI is going to be red until a new version (2.0.50) of TraceEvent is pushed to nuget.org which should happen soon (@brianrob has already bumped the version numbers in perfview repo microsoft/perfview@2c8fd78)
I have tested it locally against a local build of TraceEvent.

Fixes #447

/cc @josalem @tmds @noahfalk

@jorive jorive requested a review from josalem March 10, 2020 16:29
@brianrob
Copy link
Member

I just release TraceEvent 2.0.50. It is now available on GitHub and should be available on NuGet within the hour: https://www.nuget.org/packages/Microsoft.Diagnostics.Tracing.TraceEvent/2.0.50.

@adamsitnik
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 894 in repo dotnet/diagnostics

…void "Could not load file or assembly” error
@@ -13,6 +13,7 @@
<PackageReference Include="System.CommandLine.Experimental" Version="$(SystemCommandLineExperimentalVersion)" />
<PackageReference Include="System.CommandLine.Rendering" Version="$(SystemCommandLineRenderingVersion)" />
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="$(MicrosoftDiagnosticsTracingTraceEventVersion)" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.7.0" />
Copy link
Member Author

Choose a reason for hiding this comment

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

Without this change I was getting following error:

PS C:\Projects\diagnostics\src\Tools\dotnet-trace> dotnet run -c Release convert --format chromium
Writing:        C:\Projects\diagnostics\src\Tools\dotnet-trace\trace.chromium.json
System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at Microsoft.Diagnostics.Tracing.TraceEventRawReaders.ReadInt32(IntPtr pointer, Int32 offset)
   at Microsoft.Diagnostics.Tracing.Etlx.TraceLog.<>c__DisplayClass82_0.<SetupCallbacks>b__36(GCMarkWithTypeTraceData data)
   at Microsoft.Diagnostics.Tracing.TraceEventDispatcher.DoDispatch(TraceEvent anEvent)
   at Microsoft.Diagnostics.Tracing.EventPipeEventSource.DispatchEventRecord(EVENT_RECORD* eventRecord)
   at Microsoft.Diagnostics.Tracing.EventPipeEventSource.EventCache_OnEvent(EventPipeEventHeader& header)
   at Microsoft.Diagnostics.Tracing.EventPipe.EventCache.SortAndDispatch(Int64 stopTimestamp)
   at Microsoft.Diagnostics.Tracing.EventPipe.EventCache.ProcessEventBlock(Byte[] eventBlockData)
   at Microsoft.Diagnostics.Tracing.EventPipeBlock.FromStream(Deserializer deserializer)
   at FastSerialization.Deserializer.ReadObjectDefinition(Tags tag, StreamLabel objectLabel)
   at FastSerialization.Deserializer.ReadObject()
   at Microsoft.Diagnostics.Tracing.EventPipeEventSource.Process()
   at Microsoft.Diagnostics.Tracing.Etlx.TraceLog.CopyRawEvents(TraceEventDispatcher rawEvents, IStreamWriter writer)
   at Microsoft.Diagnostics.Tracing.Etlx.TraceLog.<>c__DisplayClass118_0.<FastSerialization.IFastSerializable.ToStream>b__0()
   at FastSerialization.DeferedRegion.Write(Serializer serializer, Action toStream)
   at Microsoft.Diagnostics.Tracing.Etlx.TraceLog.FastSerialization.IFastSerializable.ToStream(Serializer serializer)
   at FastSerialization.Serializer.WriteObjectData(IFastSerializable obj, Tags beginTag)
   at FastSerialization.Serializer.WriteObjectRef(IFastSerializable obj, Boolean defered)
   at FastSerialization.Serializer..ctor(IStreamWriter writer, IFastSerializable entryObject)
   at Microsoft.Diagnostics.Tracing.Etlx.TraceLog.CreateFromEventPipeEventSources(TraceEventDispatcher source, String etlxFilePath, TraceLogOptions options)
   at Microsoft.Diagnostics.Tracing.Etlx.TraceLog.CreateFromEventPipeDataFile(String filePath, String etlxFilePath, TraceLogOptions options)
   at Microsoft.Diagnostics.Tools.Trace.TraceFileFormatConverter.Convert(TraceFileFormat format, String fileToConvert, String outputFilename, Boolean continueOnError) in C:\Projects\diagnostics\src\Tools\dotnet-trace\TraceFileFormatConverter.cs:line 68
   at Microsoft.Diagnostics.Tools.Trace.TraceFileFormatConverter.ConvertToFormat(TraceFileFormat format, String fileToConvert, String outputFilename) in C:\Projects\diagnostics\src\Tools\dotnet-trace\TraceFileFormatConverter.cs:line 42

When I include the lastest version of the package in explicit way, the problem is gone.

@adamsitnik adamsitnik marked this pull request as ready for review March 11, 2020 09:23
@sywhang
Copy link
Contributor

sywhang commented Mar 11, 2020

Thanks Adam!! Really excited to see this :)

@tmds
Copy link
Member

tmds commented Mar 11, 2020

This is awesome! ❤️ 🚀

@brianrob
Copy link
Member

@adamsitnik, it looks like you tripped over a bug in the TraceEvent package authoring since version 2.0.50 adds a new dependency on System.Runtime.CompilerServices.Unsafe. The dependency was added but it is not expressed in the nuspec file. I have posted microsoft/perfview#1118 to fix this.

@adamsitnik
Copy link
Member Author

@brianrob nice catch! I assumed that this is some dotnet cli|MSBuild error and just worked around. It's great that you have provided a clean fix.

Copy link
Contributor

@josalem josalem left a comment

Choose a reason for hiding this comment

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

🚀 Awesome stuff @adamsitnik! @brianrob is it worth waiting for your nuspec update release of TraceEvent to merge this?

@brianrob
Copy link
Member

If you can, that would be great. That way we confirm this issue is fixed for everyone. I should have this wrapped up later today.

@brianrob
Copy link
Member

I just posted https://www.nuget.org/packages/Microsoft.Diagnostics.Tracing.TraceEvent/2.0.51 which contains the dependency fix. It should be available within the hour and should allow you to revert the extra dependency here.

@adamsitnik
Copy link
Member Author

@josalem I've updated the TraceEvent version, reverted the workaround and tested it locally. Everything works as expected, the PR is ready to be merged ;)

@josalem josalem merged commit bf74bba into dotnet:master Mar 11, 2020
@adamsitnik adamsitnik deleted the chromiumFormat branch March 12, 2020 08:33
@jnuic7
Copy link

jnuic7 commented Jul 3, 2020

It seems like it always shows 17ms as the trace runtime and leaves off most of the user code calls? Are you guys experiencing this at all. To reproduce dotnet trace collect -p 49940 --format chromium, chrome://tracing load. I see the calls show up in the json but not on the viewer

@adamsitnik
Copy link
Member Author

To reproduce dotnet trace collect -p 49940 --format chromium

Hi @jnuic7

49940 is a process runing on your machine so I can't reproduce it. Could you please create a new issue and upload the .nettrace file that dotnet trace produced for you?

@jnuic7
Copy link

jnuic7 commented Jul 3, 2020

Hey Adam, apologies was just giving a rough example by giving that process id and appreciate the quick response. Was just checking to see if you guys have run into this issue but I will open an issue

@jnuic7
Copy link

jnuic7 commented Jul 3, 2020

Just added an issue #1315. Any help is greatly appreciate and looking forward to being able to use this tool for perf profiling

@github-actions github-actions bot locked and limited conversation to collaborators Jan 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature suggestion] Converter for Trace Event json (Chrome as viewer)
7 participants