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

Added alternative flamegraph implementation that can show callers. #716

Merged
merged 2 commits into from
Aug 16, 2022

Conversation

ghemawat
Copy link
Contributor

Add an experimental flame-graph implementation. It can be selected in
pprof's web interface using the new "Flame (experimental)" menu entry.
At some point this new implementation may become the default.

The new view is similar to flame-graph view. But it can show caller
information as well. This should allow it to satisfy many users of
Graph and Peek views as well.

Let's illustrate with an example. Suppose we have profile data that
consists of the following stacks:

1000	main -> foo -> malloc
2000	main -> bar -> malloc

When main is selected, both the old and new views show:

[-------------------3000 main---------------------]
[---1000 foo-----] [----------2000 bar------------]
[---1000 malloc--] [----------2000 malloc---------]

But suppose now the user selects the right-most malloc slot.
The old view will show just the path leading to that malloc:

[----------2000 main-----------]
[----------2000 bar------------]
[----------2000 malloc---------]

The new view will however show a flame-graph view that grows
upwards that displays the call stacks leading to malloc:

[---1000 main----] [----------2000 main-----------]
[---1000 foo-----] [----------2000 bar------------]
[-------------------3000 malloc-------------------]

This caller display is useful when trying to determine expensive
callers of function.

A list of important differences between the new view and flame graphs:

New view pros:

  1. Callers are shown, e.g., all paths leading to malloc.
  2. Shows self-cost clearly with a different saturation.
  3. Font size is adjusted to fit more text into boxes.
  4. Highlighting on hover shows other occurrences of a function.
  5. Search works more like other views.
  6. Pivot changes are reflected in browser history (so back and forward
    buttons can be used to navigate between different selections).
  7. Allows eventual removal of the D3 dependency, which may make
    integrations into various environments easier.
  8. Colors provide higher contrast between foreground and background.

New view cons:

  1. There are small differences in how things look and feel.
  2. Color-scheme is very different.
  3. Change triggered by selecting a new entry is not animated.

Add an experimental flame-graph implementation. It can be selected in
pprof's web interface using the new "Flame (experimental)" menu entry.
At some point this new implementation may become the default.

The new view is similar to flame-graph view. But it can show caller
information as well. This should allow it to satisfy many users of
Graph and Peek views as well.

Let's illustrate with an example. Suppose we have profile data that
consists of the following stacks:

```
1000	main -> foo -> malloc
2000	main -> bar -> malloc
```

When main is selected, both the old and new views show:

```
[-------------------3000 main---------------------]
[---1000 foo-----] [----------2000 bar------------]
[---1000 malloc--] [----------2000 malloc---------]
```

But suppose now the user selects the right-most malloc slot.
The old view will show just the path leading to that malloc:

```
[----------2000 main-----------]
[----------2000 bar------------]
[----------2000 malloc---------]
```

The new view will however show a flame-graph view that grows
upwards that displays the call stacks leading to malloc:

```
[---1000 main----] [----------2000 main-----------]
[---1000 foo-----] [----------2000 bar------------]
[-------------------3000 malloc-------------------]
```

This caller display is useful when trying to determine expensive
callers of function.

A list of important differences between the new view and flame graphs:

New view pros:

1.  Callers are shown, e.g., all paths leading to malloc.
2.  Shows self-cost clearly with a different saturation.
3.  Font size is adjusted to fit more text into boxes.
4.  Highlighting on hover shows other occurrences of a function.
5.  Search works more like other views.
6.  Pivot changes are reflected in browser history (so back and forward
    buttons can be used to navigate between different selections).
7.  Allows eventual removal of the D3 dependency, which may make
    integrations into various environments easier.
8.  Colors provide higher contrast between foreground and background.

New view cons:

1.  There are small differences in how things look and feel.
2.  Color-scheme is very different.
3.  Change triggered by selecting a new entry is not animated.
@codecov-commenter
Copy link

Codecov Report

Merging #716 (0a19bac) into main (a41b82a) will increase coverage by 0.42%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #716      +/-   ##
==========================================
+ Coverage   64.21%   64.64%   +0.42%     
==========================================
  Files          41       45       +4     
  Lines        6495     6596     +101     
==========================================
+ Hits         4171     4264      +93     
- Misses       1881     1884       +3     
- Partials      443      448       +5     
Impacted Files Coverage Δ
.../github.com/google/pprof/internal/driver/stacks.go 66.66% <0.00%> (ø)
...hub.com/google/pprof/internal/report/shortnames.go 100.00% <0.00%> (ø)
...github.com/google/pprof/internal/report/package.go 100.00% <0.00%> (ø)
.../github.com/google/pprof/internal/report/stacks.go 87.30% <0.00%> (ø)
...c/github.com/google/pprof/internal/driver/webui.go 52.76% <0.00%> (+0.61%) ⬆️
.../github.com/google/pprof/internal/report/report.go 29.65% <0.00%> (+1.10%) ⬆️
...github.com/google/pprof/internal/driver/webhtml.go 85.71% <0.00%> (+1.71%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@ghemawat ghemawat merged commit e6338ce into google:main Aug 16, 2022
@asad-awadia
Copy link

asad-awadia commented Aug 16, 2022

Can't even fathom how it feels to review a PR from ghemawat or jdean

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.

4 participants