KEMBAR78
Implement new '--inverted' option to flip graphs vertically by simonis · Pull Request #1178 · async-profiler/async-profiler · GitHub
Skip to content

Conversation

simonis
Copy link
Contributor

@simonis simonis commented Mar 13, 2025

Description

AsyncProfiler currently supports two kind of graphs:

  • The default flame graphs which grow from bottom to top (because flames grow from bottom to top) and show the outermost frames (e.g. the main() function) at the bottom and the innermost, leaf frames at the top. They are created from stack traces which are merged starting from the outermost (e.g. main()) frames.
  • Icicle graphs which grow top-down (because icicles grow to-down) and are created from reverse stack traces, i.e. stack traces which are merged starting with the innermost, leaf frames.

Both kind of graphs can be flipped vertically with the Revert button which is located in the upper-left corner of the generated HTML page, when the graph is displayed.

But normal/reverse stack traces and icicle/flame graphs are orthogonal settings. Both kind of stack traces can be flipped vertically. Unfortunately, the vertical orientation can currently only be changed in the generated HTML page but the default orientation can not be set when the graphs are generated. It always defaults to a bottom-up, flame graph layout for normal stack traces and a top-down, icicle layout for reverse stack traces.

This PR introduces a new command line parameter --inverted which makes it possible to change the default vertical orientation for both kind of stack traces. The name of the parameter (i.e. inverted instead of inverse) is taken from Brendan Greg's original flamegraph.pl script which also provides this option.

The PR doesn't change the default behavior of AsyncProfiler. Normal stack traces are still rendered as bottom-up flame graphs and reverse stack traces are still rendered as top-down icicle, graphs. But both of these defaults can now be changed with the new --inverted=<true|false> command line option.

Related issues

See the discussion on #82 for a similar request.

Motivation and context

See Description section.

How has this been tested?

make test and manual testing of the new parameter for asprof, jfrconv and the agent use case.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@apangin apangin merged commit fe1bc66 into async-profiler:master Mar 16, 2025
9 checks passed
@apangin
Copy link
Member

apangin commented Mar 16, 2025

Merged. Thank you for the contribution!

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