This is an implementation of flame graphs right in the terminal.
For an overview of flame graphs and original implementation, check Brendan Gregg's website
While not as powerful as GUI tools, having chart right in the terminal is more convenient in case of iterative process, like:
- run a profile on remote machine
- visualize and study the profile
- make changes in code/workload/app-level settings/profiling settings/...
- repeat
In specific case of Linux perf flamereport can be seen as an alternative to running 'perf report'.
Please check http://www.brendangregg.com/flamegraphs.html
$ python flame.py < samples/osx_dtrace
- Run dtrace with -q quiet flag:
sudo dtrace -q -x stackframes=100 -n 'profile-99 /arg0/ { @[stack()] = count(); } tick-10s { exit(0); }' -o dtrace_stacks
- Get https://github.com/brendangregg/FlameGraph (needed for stack folding)
$ git clone https://github.com/brendangregg/FlameGraph.git
- Now collapse stacks:
$ ./FlameGraph/stackcollapse.pl < dtrace_stacks > stacks
- Run:
$ python ./flametui/flame.py < stacks
- Get https://github.com/brendangregg/FlameGraph (needed for stack folding)
$ git clone https://github.com/brendangregg/FlameGraph.git
- Do system-wide profile:
$ perf record -F 999 -a -g -- sleep 10
- Collapse stacks:
$ perf script | ./FlameGraph/stackcollapse-perf.pl > stacks
- View visualization
$ python ./flametui/flame.py < ./stacks
- left/h - select the block to the left
- right/l - select the block to the right
- up/k - select the block above
- down/j - select the block below
- f - focus. Zoom into selected frame; makes it fit whole width, hides the siblings.
- p - pin to top. This zooms into selected frame (like 'f') and hides parent frames. This is useful for deep traces, as there's no scrolling functionality.
- F - hard focus. Zoom into all frames with title of selected frame, pin them to top.
- x - eXclude frame. Removes the selected frame, its children and shrinks parents accordingly. This is useful when the graph is dominated by few large but not particularly interesting frames; It provides a more convenient view compared to focusing on 'smaller but more interesting' frames individually.
- r - reset focus. Resets the focus but keeps exculded frames excluded.
- R - hard reset, brings everything to default view; Useful after exclusions.
- single mouse click - select the block
- double mouse click - zoom into the block. Equivalent to 'f'
- / - search
- n/N - select next/prev block within the highlighted set of views
- q - quit
Simple selection with auto-highlight matching frames
Selecting a cell with multiple frames in it. Pressing 'n' on previous example would bring us here:
In case 'x' was used to hide some of the less interesting frames, status will show how much was excluded:
Graph element examples
- '[foo---]' -- individual frame.
- '-' - also individual frame.
- '+' - aggregated frame view which contains several frames. Selecting it will show the details in the status area. Might have hidden descendents.
- No color-coding for parts of stack traces (kernel/userspace/vm/native/etc.)