mirror of
https://github.com/fluencelabs/redis
synced 2025-06-25 23:11:33 +00:00
131
deps/jemalloc/bin/jeprof.in
vendored
131
deps/jemalloc/bin/jeprof.in
vendored
@ -95,7 +95,7 @@ my @EVINCE = ("evince"); # could also be xpdf or perhaps acroread
|
||||
my @KCACHEGRIND = ("kcachegrind");
|
||||
my @PS2PDF = ("ps2pdf");
|
||||
# These are used for dynamic profiles
|
||||
my @URL_FETCHER = ("curl", "-s", "--fail");
|
||||
my @URL_FETCHER = ("curl", "-s");
|
||||
|
||||
# These are the web pages that servers need to support for dynamic profiles
|
||||
my $HEAP_PAGE = "/pprof/heap";
|
||||
@ -223,14 +223,12 @@ Call-graph Options:
|
||||
--nodefraction=<f> Hide nodes below <f>*total [default=.005]
|
||||
--edgefraction=<f> Hide edges below <f>*total [default=.001]
|
||||
--maxdegree=<n> Max incoming/outgoing edges per node [default=8]
|
||||
--focus=<regexp> Focus on backtraces with nodes matching <regexp>
|
||||
--focus=<regexp> Focus on nodes matching <regexp>
|
||||
--thread=<n> Show profile for thread <n>
|
||||
--ignore=<regexp> Ignore backtraces with nodes matching <regexp>
|
||||
--ignore=<regexp> Ignore nodes matching <regexp>
|
||||
--scale=<n> Set GV scaling [default=0]
|
||||
--heapcheck Make nodes with non-0 object counts
|
||||
(i.e. direct leak generators) more visible
|
||||
--retain=<regexp> Retain only nodes that match <regexp>
|
||||
--exclude=<regexp> Exclude all nodes that match <regexp>
|
||||
|
||||
Miscellaneous:
|
||||
--tools=<prefix or binary:fullpath>[,...] \$PATH for object tool pathnames
|
||||
@ -341,8 +339,6 @@ sub Init() {
|
||||
$main::opt_ignore = '';
|
||||
$main::opt_scale = 0;
|
||||
$main::opt_heapcheck = 0;
|
||||
$main::opt_retain = '';
|
||||
$main::opt_exclude = '';
|
||||
$main::opt_seconds = 30;
|
||||
$main::opt_lib = "";
|
||||
|
||||
@ -414,8 +410,6 @@ sub Init() {
|
||||
"ignore=s" => \$main::opt_ignore,
|
||||
"scale=i" => \$main::opt_scale,
|
||||
"heapcheck" => \$main::opt_heapcheck,
|
||||
"retain=s" => \$main::opt_retain,
|
||||
"exclude=s" => \$main::opt_exclude,
|
||||
"inuse_space!" => \$main::opt_inuse_space,
|
||||
"inuse_objects!" => \$main::opt_inuse_objects,
|
||||
"alloc_space!" => \$main::opt_alloc_space,
|
||||
@ -1166,21 +1160,8 @@ sub PrintSymbolizedProfile {
|
||||
}
|
||||
print '---', "\n";
|
||||
|
||||
my $profile_marker;
|
||||
if ($main::profile_type eq 'heap') {
|
||||
$HEAP_PAGE =~ m,[^/]+$,; # matches everything after the last slash
|
||||
$profile_marker = $&;
|
||||
} elsif ($main::profile_type eq 'growth') {
|
||||
$GROWTH_PAGE =~ m,[^/]+$,; # matches everything after the last slash
|
||||
$profile_marker = $&;
|
||||
} elsif ($main::profile_type eq 'contention') {
|
||||
$CONTENTION_PAGE =~ m,[^/]+$,; # matches everything after the last slash
|
||||
$profile_marker = $&;
|
||||
} else { # elsif ($main::profile_type eq 'cpu')
|
||||
$PROFILE_PAGE =~ m,[^/]+$,; # matches everything after the last slash
|
||||
$profile_marker = $&;
|
||||
}
|
||||
|
||||
$PROFILE_PAGE =~ m,[^/]+$,; # matches everything after the last slash
|
||||
my $profile_marker = $&;
|
||||
print '--- ', $profile_marker, "\n";
|
||||
if (defined($main::collected_profile)) {
|
||||
# if used with remote fetch, simply dump the collected profile to output.
|
||||
@ -1190,12 +1171,6 @@ sub PrintSymbolizedProfile {
|
||||
}
|
||||
close(SRC);
|
||||
} else {
|
||||
# --raw/http: For everything to work correctly for non-remote profiles, we
|
||||
# would need to extend PrintProfileData() to handle all possible profile
|
||||
# types, re-enable the code that is currently disabled in ReadCPUProfile()
|
||||
# and FixCallerAddresses(), and remove the remote profile dumping code in
|
||||
# the block above.
|
||||
die "--raw/http: jeprof can only dump remote profiles for --raw\n";
|
||||
# dump a cpu-format profile to standard out
|
||||
PrintProfileData($profile);
|
||||
}
|
||||
@ -2846,43 +2821,6 @@ sub ExtractCalls {
|
||||
return $calls;
|
||||
}
|
||||
|
||||
sub FilterFrames {
|
||||
my $symbols = shift;
|
||||
my $profile = shift;
|
||||
|
||||
if ($main::opt_retain eq '' && $main::opt_exclude eq '') {
|
||||
return $profile;
|
||||
}
|
||||
|
||||
my $result = {};
|
||||
foreach my $k (keys(%{$profile})) {
|
||||
my $count = $profile->{$k};
|
||||
my @addrs = split(/\n/, $k);
|
||||
my @path = ();
|
||||
foreach my $a (@addrs) {
|
||||
my $sym;
|
||||
if (exists($symbols->{$a})) {
|
||||
$sym = $symbols->{$a}->[0];
|
||||
} else {
|
||||
$sym = $a;
|
||||
}
|
||||
if ($main::opt_retain ne '' && $sym !~ m/$main::opt_retain/) {
|
||||
next;
|
||||
}
|
||||
if ($main::opt_exclude ne '' && $sym =~ m/$main::opt_exclude/) {
|
||||
next;
|
||||
}
|
||||
push(@path, $a);
|
||||
}
|
||||
if (scalar(@path) > 0) {
|
||||
my $reduced_path = join("\n", @path);
|
||||
AddEntry($result, $reduced_path, $count);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub RemoveUninterestingFrames {
|
||||
my $symbols = shift;
|
||||
my $profile = shift;
|
||||
@ -3027,9 +2965,6 @@ sub RemoveUninterestingFrames {
|
||||
my $reduced_path = join("\n", @path);
|
||||
AddEntry($result, $reduced_path, $count);
|
||||
}
|
||||
|
||||
$result = FilterFrames($symbols, $result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -3339,7 +3274,7 @@ sub ResolveRedirectionForCurl {
|
||||
# Add a timeout flat to URL_FETCHER. Returns a new list.
|
||||
sub AddFetchTimeout {
|
||||
my $timeout = shift;
|
||||
my @fetcher = @_;
|
||||
my @fetcher = shift;
|
||||
if (defined($timeout)) {
|
||||
if (join(" ", @fetcher) =~ m/\bcurl -s/) {
|
||||
push(@fetcher, "--max-time", sprintf("%d", $timeout));
|
||||
@ -3385,27 +3320,6 @@ sub ReadSymbols {
|
||||
return $map;
|
||||
}
|
||||
|
||||
sub URLEncode {
|
||||
my $str = shift;
|
||||
$str =~ s/([^A-Za-z0-9\-_.!~*'()])/ sprintf "%%%02x", ord $1 /eg;
|
||||
return $str;
|
||||
}
|
||||
|
||||
sub AppendSymbolFilterParams {
|
||||
my $url = shift;
|
||||
my @params = ();
|
||||
if ($main::opt_retain ne '') {
|
||||
push(@params, sprintf("retain=%s", URLEncode($main::opt_retain)));
|
||||
}
|
||||
if ($main::opt_exclude ne '') {
|
||||
push(@params, sprintf("exclude=%s", URLEncode($main::opt_exclude)));
|
||||
}
|
||||
if (scalar @params > 0) {
|
||||
$url = sprintf("%s?%s", $url, join("&", @params));
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
# Fetches and processes symbols to prepare them for use in the profile output
|
||||
# code. If the optional 'symbol_map' arg is not given, fetches symbols from
|
||||
# $SYMBOL_PAGE for all PC values found in profile. Otherwise, the raw symbols
|
||||
@ -3430,11 +3344,9 @@ sub FetchSymbols {
|
||||
my $command_line;
|
||||
if (join(" ", @URL_FETCHER) =~ m/\bcurl -s/) {
|
||||
$url = ResolveRedirectionForCurl($url);
|
||||
$url = AppendSymbolFilterParams($url);
|
||||
$command_line = ShellEscape(@URL_FETCHER, "-d", "\@$main::tmpfile_sym",
|
||||
$url);
|
||||
} else {
|
||||
$url = AppendSymbolFilterParams($url);
|
||||
$command_line = (ShellEscape(@URL_FETCHER, "--post", $url)
|
||||
. " < " . ShellEscape($main::tmpfile_sym));
|
||||
}
|
||||
@ -3515,22 +3427,12 @@ sub FetchDynamicProfile {
|
||||
}
|
||||
$url .= sprintf("seconds=%d", $main::opt_seconds);
|
||||
$fetch_timeout = $main::opt_seconds * 1.01 + 60;
|
||||
# Set $profile_type for consumption by PrintSymbolizedProfile.
|
||||
$main::profile_type = 'cpu';
|
||||
} else {
|
||||
# For non-CPU profiles, we add a type-extension to
|
||||
# the target profile file name.
|
||||
my $suffix = $path;
|
||||
$suffix =~ s,/,.,g;
|
||||
$profile_file .= $suffix;
|
||||
# Set $profile_type for consumption by PrintSymbolizedProfile.
|
||||
if ($path =~ m/$HEAP_PAGE/) {
|
||||
$main::profile_type = 'heap';
|
||||
} elsif ($path =~ m/$GROWTH_PAGE/) {
|
||||
$main::profile_type = 'growth';
|
||||
} elsif ($path =~ m/$CONTENTION_PAGE/) {
|
||||
$main::profile_type = 'contention';
|
||||
}
|
||||
}
|
||||
|
||||
my $profile_dir = $ENV{"JEPROF_TMPDIR"} || ($ENV{HOME} . "/jeprof");
|
||||
@ -3828,8 +3730,6 @@ sub ReadProfile {
|
||||
my $symbol_marker = $&;
|
||||
$PROFILE_PAGE =~ m,[^/]+$,; # matches everything after the last slash
|
||||
my $profile_marker = $&;
|
||||
$HEAP_PAGE =~ m,[^/]+$,; # matches everything after the last slash
|
||||
my $heap_marker = $&;
|
||||
|
||||
# Look at first line to see if it is a heap or a CPU profile.
|
||||
# CPU profile may start with no header at all, and just binary data
|
||||
@ -3856,13 +3756,7 @@ sub ReadProfile {
|
||||
$header = ReadProfileHeader(*PROFILE) || "";
|
||||
}
|
||||
|
||||
if ($header =~ m/^--- *($heap_marker|$growth_marker)/o) {
|
||||
# Skip "--- ..." line for profile types that have their own headers.
|
||||
$header = ReadProfileHeader(*PROFILE) || "";
|
||||
}
|
||||
|
||||
$main::profile_type = '';
|
||||
|
||||
if ($header =~ m/^heap profile:.*$growth_marker/o) {
|
||||
$main::profile_type = 'growth';
|
||||
$result = ReadHeapProfile($prog, *PROFILE, $header);
|
||||
@ -3914,9 +3808,9 @@ sub ReadProfile {
|
||||
# independent implementation.
|
||||
sub FixCallerAddresses {
|
||||
my $stack = shift;
|
||||
# --raw/http: Always subtract one from pc's, because PrintSymbolizedProfile()
|
||||
# dumps unadjusted profiles.
|
||||
{
|
||||
if ($main::use_symbolized_profile) {
|
||||
return $stack;
|
||||
} else {
|
||||
$stack =~ /(\s)/;
|
||||
my $delimiter = $1;
|
||||
my @addrs = split(' ', $stack);
|
||||
@ -3984,7 +3878,12 @@ sub ReadCPUProfile {
|
||||
for (my $j = 0; $j < $d; $j++) {
|
||||
my $pc = $slots->get($i+$j);
|
||||
# Subtract one from caller pc so we map back to call instr.
|
||||
$pc--;
|
||||
# However, don't do this if we're reading a symbolized profile
|
||||
# file, in which case the subtract-one was done when the file
|
||||
# was written.
|
||||
if ($j > 0 && !$main::use_symbolized_profile) {
|
||||
$pc--;
|
||||
}
|
||||
$pc = sprintf("%0*x", $address_length, $pc);
|
||||
$pcs->{$pc} = 1;
|
||||
push @k, $pc;
|
||||
|
Reference in New Issue
Block a user