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

Flame Graph #440

Closed
wants to merge 887 commits into from
Closed

Flame Graph #440

wants to merge 887 commits into from

Conversation

adamsitnik
Copy link
Member

PerfView is very powerful tool, but sometimes for some inexperienced users like me it is hard to get a fast overview of what takes most of the CPU if there are plenty of methods on the stack.

This PR provides a simple implementation of the "Flame Graph".

It is just different visualization of the "call tree" view.

Sample result (for the "tutorial.exe")

image

Sample result for more complicated app (dotnet cli):

image

  1. I added new tab (before the "notes")
  2. I did not use SVG (most common way of implementing flame graph) because I would have to add external dependency to the project (link)
  3. I decided to draw the rectangles/textblocks on a simple WPF Canvas. For small boxes, I use rectangles (too many textblocks on a single canvas = bad perf)
  4. I have used some fancy color pallet to differentiate the boxes
  5. I added possibility to export the flame graph to png file (right click => save)
  6. I added the docs
  7. The canvas is redrawn on resize/when the tab gets the focus
  8. Both tool tip and bottom panel contains method name, samples count and % of total time
  9. Since the flame graph is using data from call tree view, any filter applied to call tree view works for flame graph as well

vancem and others added 30 commits July 10, 2017 05:48
…oseTraceData to reflect MethodLoadUnloadVerbose_V2 manifest
HistoryDictionary: Replace manually sorted list with SortedDictionary
…osoft-Windows-DotNETRuntime/Method/LoadVerbose events
Update MethodLoadUnloadVerboseTraceData to reflect MethodLoadUnloadVerbose_V2 manifest
Include Microsoft.Diagnostics.FastSerialization in the TraceEvent package
This is missing and is an essential part of the package.
Tell people how to build without using Visual Studio IDE.
Add the OSExtentions DLL to the TraceEvent Nuget package
When parsing timestamp of an event ("0.0") with the current
culture set to "fr-FR", a System.FormatException is raised.
When parsing timestamp of an event ("0.0") with the current
culture set to "fr-FR", a System.FormatException is raised.
This member is needed to parse events in a high performance way (no copying)
It was protected because the common scenario is to use this in TraceEvent subclasses
but it can be useful for ad-hoc pointer based parsing, so we are making it public.
Make The DataStart property public
Fix LinuxPerfScriptEventParser when parsing timespamp event
Use the codecov uploader from NuGet
…g\TraceProcess sets these fields is via the tracelog. This portion of the code (as it transitions to a source based model) does not have access to the right information. The *RelativeMsec data is stored as the process is inspected on events.
sharwell and others added 15 commits November 3, 2017 09:12
The documentation implied that you only had to match one IncPat for
a sample to be included, which isn't correct. This was particularly
confusing since the documentation continued discussing an OR operator.
Remove TraceEventNativeMethods.ZeroMemory
Added the Gen 2 object Deaths view for 100K Sampling
Improve the performance of CallTreeNode.AllCallees
Improve debugging experience by omitting children from Node.ToString()
We need to install a .NET Profiler via the registry for some PerfView operations.
We were not being agressive enough to clean up even, if things are partly wrong.
This can leave stale state behind.  This improves the robustness.
Fix logic that touches registry to be very robust
@msftclas
Copy link

msftclas commented Nov 16, 2017

CLA assistant check
All CLA requirements met.

@codecov-io
Copy link

Codecov Report

Merging #440 into master will decrease coverage by 0.01%.
The diff coverage is 5.07%.

@@            Coverage Diff             @@
##           master     #440      +/-   ##
==========================================
- Coverage   17.54%   17.52%   -0.02%     
==========================================
  Files         213      214       +1     
  Lines      122889   123027     +138     
  Branches    11839    11855      +16     
==========================================
+ Hits        21555    21562       +7     
- Misses     100475   100606     +131     
  Partials      859      859
Flag Coverage Δ
#2017 17.52% <5.07%> (-0.02%) ⬇️
#Debug 17.52% <5.07%> (-0.02%) ⬇️
#Release 100% <ø> (ø) ⬆️
Impacted Files Coverage Δ
src/PerfView/FlameGraph.cs 0% <0%> (ø)
src/PerfView/StackViewer/StackWindow.xaml 100% <100%> (ø) ⬆️
src/PerfView/StackViewer/StackWindow.xaml.cs 23.82% <9.52%> (-0.24%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 118f6bc...6e5c1c1. Read the comment docs.

1 similar comment
@codecov-io
Copy link

Codecov Report

Merging #440 into master will decrease coverage by 0.01%.
The diff coverage is 5.07%.

@@            Coverage Diff             @@
##           master     #440      +/-   ##
==========================================
- Coverage   17.54%   17.52%   -0.02%     
==========================================
  Files         213      214       +1     
  Lines      122889   123027     +138     
  Branches    11839    11855      +16     
==========================================
+ Hits        21555    21562       +7     
- Misses     100475   100606     +131     
  Partials      859      859
Flag Coverage Δ
#2017 17.52% <5.07%> (-0.02%) ⬇️
#Debug 17.52% <5.07%> (-0.02%) ⬇️
#Release 100% <ø> (ø) ⬆️
Impacted Files Coverage Δ
src/PerfView/FlameGraph.cs 0% <0%> (ø)
src/PerfView/StackViewer/StackWindow.xaml 100% <100%> (ø) ⬆️
src/PerfView/StackViewer/StackWindow.xaml.cs 23.82% <9.52%> (-0.24%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 118f6bc...6e5c1c1. Read the comment docs.

@codecov-io
Copy link

codecov-io commented Nov 16, 2017

Codecov Report

Merging #440 into master will decrease coverage by 0.04%.
The diff coverage is 13.33%.

@@            Coverage Diff             @@
##           master     #440      +/-   ##
==========================================
- Coverage   17.57%   17.52%   -0.05%     
==========================================
  Files         216      214       -2     
  Lines      123202   123027     -175     
  Branches    11879    11855      -24     
==========================================
- Hits        21654    21562      -92     
+ Misses     100684   100606      -78     
+ Partials      864      859       -5
Flag Coverage Δ
#2017 17.52% <13.33%> (-0.05%) ⬇️
#Debug 17.52% <13.33%> (-0.05%) ⬇️
#Release 100% <ø> (?)
Impacted Files Coverage Δ
src/LinuxEvent.Tests/Constants.cs 100% <ø> (ø) ⬆️
src/LinuxEvent.Tests/BlockedTimeTests.cs 71.42% <ø> (ø) ⬆️
...rc/PerfView.TestUtilities/ThrowingTraceListener.cs 12.72% <ø> (ø) ⬆️
src/PerfView/CommandProcessor.cs 0.17% <ø> (ø) ⬆️
src/LinuxEvent.Tests/FastStreamTests.cs 100% <ø> (ø) ⬆️
src/FastSerialization/GrowableArray.cs 61.45% <ø> (ø) ⬆️
src/MemoryGraph/graph.cs 0% <ø> (ø) ⬆️
src/PerfView/Dialogs/RunCommandDialog.xaml 0% <ø> (ø) ⬆️
src/PerfView.TestUtilities/UseCultureAttribute.cs 100% <ø> (ø) ⬆️
src/PerfView/App.cs 2.72% <ø> (+0.01%) ⬆️
... and 51 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update db30b4c...6e5c1c1. Read the comment docs.

@goldshtn
Copy link

I love this! I know it will help a lot of users figure out at a glance what’s happening in their call tree.

Would the folding and grouping from the tree view be applied to the flame graph as well?

Finally in terms of the palette, it might make sense to use a default palette for .NET processes where the .NET frames, CLR frames, Windows library frames, and kernel frames are colored using different palettes. (Like the flamegraph.pl Java palette, for example.)

+100000

@adamsitnik
Copy link
Member Author

Would the folding and grouping from the tree view be applied to the flame graph as well?

@goldshtn yes, I am reusing the data generated for the call tree, so I get all of it's advantages out of the box

tutorial.exe with default grouping:

image

tutorial.exe with no grouping

image

@adamsitnik
Copy link
Member Author

Finally in terms of the palette, it might make sense to use a default palette for .NET processes where the .NET frames, CLR frames, Windows library frames, and kernel frames are colored using different palettes. (Like the flamegraph.pl Java palette, for example.)

@goldshtn I really like this idea, but I have not found a way to implement it yet. My problem is that based on the name of the method I currently can not say to which group it belongs (it is just a string). I need to dig into the code of PerfView and do some PoC. Maybe I could use the existing grouping regexes to do it? It looks like perfect candidate

@ilabutin
Copy link
Contributor

@adamsitnik Wait, if you're reusing same call tree, then all grouping is already done for you. So maybe all CLR calls are already grouped into "CLR" nodes. So, I would suggest to start with highlighting different folded groups with different palettes - it will already give nice visual understanding of how these groups are distributed.
And then, in addition, you can add more advanced highlighting based on module/method names which were not grouped.

@adamsitnik
Copy link
Member Author

due to some problems with GIT I need to recreate my fork. Flame graphs will be back ;)

@adamsitnik adamsitnik closed this Jan 5, 2018
@adamsitnik adamsitnik mentioned this pull request Jan 5, 2018
@adamsitnik
Copy link
Member Author

Recreated #502

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.