timholy / FlameGraphs.jl

Analysis of profiling data using trees
MIT License
51 stars 12 forks source link

Add PProf to the list of packages that support `FlameGraphs` #32

Closed NHDaly closed 3 years ago

NHDaly commented 3 years ago

As of https://github.com/JuliaPerf/PProf.jl/pull/25, and release v1.2.0, PProf.jl has supported displaying FlameGraphs directly, via:

using PProf
pprof(fg)

I'm not sure of what order to put this in. I put it last, since it's the newest, but I'd probably prefer to put it either right below ProfileView or right below Juno, since it's one of the main interactive profile viewers in julia, whereas the others are either specific to exporting or specific to notebooks. :) Thanks!

codecov[bot] commented 3 years ago

Codecov Report

Merging #32 (033ce6e) into master (82b41fb) will decrease coverage by 1.84%. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #32      +/-   ##
==========================================
- Coverage   95.47%   93.63%   -1.85%     
==========================================
  Files           5        5              
  Lines         243      267      +24     
==========================================
+ Hits          232      250      +18     
- Misses         11       17       +6     
Impacted Files Coverage Δ
src/FlameGraphs.jl 42.85% <0.00%> (-41.76%) :arrow_down:
src/io.jl 98.18% <0.00%> (+0.14%) :arrow_up:
src/render.jl 98.59% <0.00%> (+0.15%) :arrow_up:
src/graph.jl 94.56% <0.00%> (+0.51%) :arrow_up:
src/sfcategory.jl 94.28% <0.00%> (+0.73%) :arrow_up:

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 82b41fb...d8d361c. Read the comment docs.

NHDaly commented 3 years ago

In the second commit I just added, I tried to expand a bit on the pros and cons of PProf. I'm not sure if you think that's worth including?

timholy commented 3 years ago

I'd be fine with moving it up the list, particularly because it offers more functionality. Or, we could have two sections: one that is basically "frontends like ProfileView" and the other "frontends that provide something different." Of course, over time we might imagine more of those extra analyses being implemented in FlameGraphs/ProfileView, so maybe that would be a bit hard to justify in the long run.

I'd be interested in hearing sometime about the most useful benefits PProf brings, or perhaps I'll just have to play with it and discover for myself :-).

NHDaly commented 3 years ago

Hokay thanks :)

I've put it right after ProfileView now. Lemme know how this looks! Thanks.

I'd be interested in hearing sometime about the most useful benefits PProf brings, or perhaps I'll just have to play with it and discover for myself :-).

:) Yeah, please let us know what you think! It's just a wrapper around Google's pprof tool, but thankfully they seem somewhat open to PRs (I've recently fixed their string escaping which was having issues with julia function names that have a " in them 😅), so we can ensure julia is well-supported.

In my opinion, the main benefits are its interactivity: For the flame graph, the ability to highlight and filter frames and stacks by keyword, and the fact that it shows the names for all the frames at once, all make it easier to "look around," and explore, I think. Then the other views also help you get another perspective on the profile. The source view shows aggregated counts per line. The graph view lets you look at an aggregated view of the profile, which can be helpful to find the total cost of some code, e.g. the total cost of a small function that shows up a lot of times can be hidden in a flamegraph, but pop out in the graph view. And the trace information is still there via the arrows, so it's technically a superset of the information in the flamegraph, but I think the flamegraph is easier to read. (Also the graph view compresses and filters out some frames, which is annoying.)

The main drawback in my opinion is that the traces aren't ordered in the flamegraph view.

From what I've found, I think ProfileView's main advantages (though I similarly haven't used it as much, so very likely I'm missing some understanding!) are 1. the ordered traces, and 2. the close tie-in with Julia: directly highlighting things like compilation time, and dynamic dispatches, and type instability.

^^ Interested in others' thoughts, in case i missed anything! :)

CC: @vchuravy

timholy commented 3 years ago

Sounds good. Does it support click-to-edit-the-source-code too?

NHDaly commented 3 years ago

Sounds good. Does it support click-to-edit-the-source-code too?

Oooh, no it certainly doesn't! I hadn't seen that before - that's nice. :)

timholy commented 3 years ago

Right-click in ProfileView.

NHDaly commented 3 years ago

🖱️