Skip to content

Commit

Permalink
Merge branch 'master' into java-frame-detection
Browse files Browse the repository at this point in the history
  • Loading branch information
brendangregg authored Aug 31, 2021
2 parents 88f6cfe + be7d6b9 commit daa09f8
Show file tree
Hide file tree
Showing 17 changed files with 1,010 additions and 209 deletions.
45 changes: 28 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
Main Website: http://www.brendangregg.com/flamegraphs.html

Example (click to zoom):

[![Example](http://www.brendangregg.com/FlameGraphs/cpu-bash-flamegraph.svg)](http://www.brendangregg.com/FlameGraphs/cpu-bash-flamegraph.svg)

Click a box to zoom the Flame Graph to this stack frame only.
To search and highlight all stack frames matching a regular expression, click the _search_ button in the upper right corner or press Ctrl-F.
By default, search is case sensitive, but this can be toggled by pressing Ctrl-I or by clicking the _ic_ button in the upper right corner.

Other sites:
- The Flame Graph article in ACMQ and CACM: http://queue.acm.org/detail.cfm?id=2927301 http://cacm.acm.org/magazines/2016/6/202665-the-flame-graph/abstract
- CPU profiling using Linux perf\_events, DTrace, SystemTap, or ktap: http://www.brendangregg.com/FlameGraphs/cpuflamegraphs.html
Expand Down Expand Up @@ -76,6 +81,7 @@ Use the stackcollapse programs to fold stack samples into single lines. The pro
- `stackcollapse-gdb.pl`: for gdb(1) stacks
- `stackcollapse-go.pl`: for Golang pprof stacks
- `stackcollapse-vsprof.pl`: for Microsoft Visual Studio profiles
- `stackcollapse-wcp.pl`: for wallClockProfiler output

Usage example:

Expand Down Expand Up @@ -157,23 +163,28 @@ See the USAGE message (--help) for options:

USAGE: ./flamegraph.pl [options] infile > outfile.svg

--title # change title text
--width # width of image (default 1200)
--height # height of each frame (default 16)
--minwidth # omit smaller functions (default 0.1 pixels)
--fonttype # font type (default "Verdana")
--fontsize # font size (default 12)
--countname # count type label (default "samples")
--nametype # name type label (default "Function:")
--colors # set color palette. choices are: hot (default), mem, io,
# wakeup, chain, java, js, perl, red, green, blue, aqua,
# yellow, purple, orange
--hash # colors are keyed by function name hash
--cp # use consistent palette (palette.map)
--reverse # generate stack-reversed flame graph
--inverted # icicle graph
--negate # switch differential hues (blue<->red)
--help # this message
--title TEXT # change title text
--subtitle TEXT # second level title (optional)
--width NUM # width of image (default 1200)
--height NUM # height of each frame (default 16)
--minwidth NUM # omit smaller functions (default 0.1 pixels)
--fonttype FONT # font type (default "Verdana")
--fontsize NUM # font size (default 12)
--countname TEXT # count type label (default "samples")
--nametype TEXT # name type label (default "Function:")
--colors PALETTE # set color palette. choices are: hot (default), mem,
# io, wakeup, chain, java, js, perl, red, green, blue,
# aqua, yellow, purple, orange
--bgcolors COLOR # set background colors. gradient choices are yellow
# (default), blue, green, grey; flat colors use "#rrggbb"
--hash # colors are keyed by function name hash
--cp # use consistent palette (palette.map)
--reverse # generate stack-reversed flame graph
--inverted # icicle graph
--flamechart # produce a flame chart (sort by time, do not merge stacks)
--negate # switch differential hues (blue<->red)
--notes TEXT # add notes comment in SVG (for debugging)
--help # this message

eg,
./flamegraph.pl --title="Flame Graph: malloc()" trace.txt > graph.svg
Expand Down
2 changes: 1 addition & 1 deletion dev/hcstackcollapse.pl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
#
# hcstackcolllapse.pl collapse hot/cold multiline stacks into single lines.
# hcstackcollapse.pl collapse hot/cold multiline stacks into single lines.
#
# EXPERIMENTAL: This is a work in progress, and may not work properly.
#
Expand Down
23 changes: 21 additions & 2 deletions files.pl
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,44 @@
use File::Find;

sub usage {
print STDERR "USAGE: $0 directory\n";
print STDERR "USAGE: $0 [--xdev] [DIRECTORY]...\n";
print STDERR " eg, $0 /Users\n";
print STDERR " To not descend directories on other filesystems:";
print STDERR " eg, $0 --xdev /\n";
print STDERR "Intended to be piped to flamegraph.pl. Full example:\n";
print STDERR " $0 /Users | flamegraph.pl " .
"--hash --countname=bytes > files.svg\n";
print STDERR " $0 /usr /home /root /etc | flamegraph.pl " .
"--hash --countname=bytes > files.svg\n";
print STDERR " $0 --xdev / | flamegraph.pl " .
"--hash --countname=bytes > files.svg\n";
exit 1;
}

usage() if @ARGV == 0 or $ARGV[0] eq "--help" or $ARGV[0] eq "-h";

my $filter_xdev = 0;
my $xdev_id;

foreach my $dir (@ARGV) {
find(\&wanted, $dir);
if ($dir eq "--xdev") {
$filter_xdev = 1;
} else {
find(\&wanted, $dir);
}
}

sub wanted {
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size) = lstat($_);
return unless defined $size;
if ($filter_xdev) {
if (!$xdev_id) {
$xdev_id = $dev;
} elsif ($xdev_id ne $dev) {
$File::Find::prune = 1;
return;
}
}
my $path = $File::Find::name;
$path =~ tr/\//;/; # delimiter
$path =~ tr/;.a-zA-Z0-9-/_/c; # ditch whitespace and other chars
Expand Down
Loading

0 comments on commit daa09f8

Please sign in to comment.