Skip to content

Runtime Loader advanced event view#1232

Merged
brianrob merged 14 commits intomicrosoft:masterfrom
davidwrighton:runtimeops_v2
Aug 21, 2020
Merged

Runtime Loader advanced event view#1232
brianrob merged 14 commits intomicrosoft:masterfrom
davidwrighton:runtimeops_v2

Conversation

@davidwrighton
Copy link
Member

Add support for viewing various when various runtime load operations occur during process execution. This is a view much like jit stats, but somewhat more flexible and less specialized to just the JIT.

Events visible are

The view is presented linearly per thread, and can be shown nested or not (nested allows understanding of which operations occur as a result of other operations)

In addition, which events are shown is configurable via checkbox.

@davidwrighton
Copy link
Member Author

@BILLwer @brianrob Could one of you review this?

@brianrob
Copy link
Member

Yes, I will take a look @davidwrighton.

<Compile Include="..\PerfView\ClrStats.cs" />
<Compile Include="..\PerfView\GcStats.cs" />
<Compile Include="..\PerfView\JitStats.cs" />
<Compile Include="..\PerfView\RuntimeLoaderStats.cs" />
Copy link
Member

Choose a reason for hiding this comment

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

Are you wanting to enable this via the PerfViewCollect tool?

Copy link
Member Author

Choose a reason for hiding this comment

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

Eventually... yes. But for now, I'm settling for it just building cleanly. This change was required for that. The rest of these changes, are VS doing something I didn't want.


<ItemGroup>
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent.SupportFiles" Version="$(MicrosoftDiagnosticsTracingTraceEventSupportFilesVersion)" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-63127-02" PrivateAssets="All"/>
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 a bunch of whitespace change here. Can you revert these please? Let me know if I missed an actual change here.

To enable data about all loader operations set the ".NET Loader" checkbox when collecting data.
Otherwise, the data captured will be restricted to JIT and assembly load operations. The /RuntimeLoading switch may also be used.

Also see the Runtime Loader stacks view, which ties this data into a view of CPU activity, to allow investigating CPU usage during specific loader operations.
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 help for this. Can you also add a note that this only works on .NET Core (assuming we're not porting this to desktop)?

Copy link
Member Author

Choose a reason for hiding this comment

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

It actually works to some extent on desktop. You can see JIT and assembly load events there.


<CheckBox Grid.Row="0" Grid.Column="13" Name="Unused2" Visibility="Hidden" VerticalAlignment="Center"/>
<TextBlock Grid.Row="0" Grid.Column="12" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="8,2,5,2"
ToolTip="Log information about .NET Runtime loading." >
Copy link
Member

Choose a reason for hiding this comment

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

It might be good to disambiguate this a bit in the tooltip to be clear that this is for more than just assembly loading, but also type loading, method loading, etc.


foreach (var proc in runtimeOps.EventSource.TraceLog.Processes)
{
if (proc.ProcessID == incompleteStatsProc.ProcessID)
Copy link
Member

Choose a reason for hiding this comment

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

There are a couple of ways that you can match processes, while handing the fact that process IDs can be re-used. One is to use TraceProcess.ProcessIndex, which is a unique value across the entire trace. The second is to use ProcessID and timestamp, and find the closest match - TraceLog.Processes has an API for this. If you leave this as is, it's possible that PID re-use will impact the results here.

Copy link
Member

Choose a reason for hiding this comment

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

In RuntimeLoaderStats.cs, you are using Microsoft.Diagnostics.Tracing.Etlx.TraceProcess, but here you're using Microsoft.Diagnostics.Tracing.Analysis.TraceProcess. They are slightly different. The first is layered on top of TraceLog, while this one is a level lower at TraceEventSource. Since you already require Etlx.TraceProcess, I'd recommend just using that everywhere, and then you can use ProcessIndex rather than PID.


In reply to: 458422874 [](ancestors = 458422874)


foreach (var proc in runtimeOps.EventSource.TraceLog.Processes)
{
if (proc.ProcessID == incompleteStatsProc.ProcessID)
Copy link
Member

Choose a reason for hiding this comment

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

Same PID re-use issue here.


advanced.Children.Add(new PerfViewJitStats(this));

advanced.Children.Add(new PerfViewRuntimeLoaderStats(this));
Copy link
Member

@brianrob brianrob Jul 21, 2020

Choose a reason for hiding this comment

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

Can you condition this on having enough data in the trace to show something? You're just looking for the specific types of events that you need. We do this so that there aren't views that don't show anything.

Copy link
Member

@brianrob brianrob left a comment

Choose a reason for hiding this comment

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

Thanks for submitting this @davidwrighton. Overall looks good - some comments and recommendations. Also, can you share a trace that you've captured with these events? I'm interested to see the view in action.

source.Clr.LoaderTypeLoadStart += Clr_LoaderTypeLoadStart;
source.Clr.LoaderTypeLoadStop += Clr_LoaderTypeLoadStop;
source.Process();
source.Clr.MethodJittingStarted -= Clr_MethodJittingStarted;
Copy link
Member

Choose a reason for hiding this comment

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

You should not need to unsubscribe these delegates. The pattern used is to provide a fresh EventSource so that you are sure that other machinery isn't subscribed if you are concerned about this. I don't think you'll find many, if any, places in where we attempt to unsubscribe in order to re-use the EventSource.

Add support for generating csv as well as txt and make output generally
acceptable to excel
- Consistently use the Microsoft.Diagnostics.Tracing.Analysis.TraceProcess
- Refactor CLRRuntimeActivityComputer to be more pluggable into the existing Process once model
- Only display view when it has data
- Properly segregate process local data and handle process id reuse
- Update help text and documentation to be more accurate
@davidwrighton
Copy link
Member Author

@brianrob I've addressed all of the feedback you've given me. As it turns out it was more difficult to consolidate on using the Etlx TraceProcess, so instead I consolidated on working with the Analysis TraceProcess, and some modestly dodgy logic involving pids and timestamps.

Copy link
Member

@brianrob brianrob left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@brianrob brianrob merged commit b33df66 into microsoft:master Aug 21, 2020
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.

2 participants