Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 7041720

Browse files
committed
Rename pprof to jeprof.
This rename avoids installation collisions with the upstream gperftools. Additionally, jemalloc's per thread heap profile functionality introduced an incompatible file format, so it's now worthwhile to clearly distinguish jemalloc's version of this script from the upstream version. This resolves jemalloc#229.
1 parent 8e33c21 commit 7041720

File tree

7 files changed

+68
-63
lines changed

7 files changed

+68
-63
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
/bin/jemalloc-config
44
/bin/jemalloc.sh
5+
/bin/jeprof
56

67
/config.stamp
78
/config.log

ChangeLog

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,9 @@ found in the git revision history:
117117
- Assure that the constness of malloc_usable_size()'s return type matches that
118118
of the system implementation.
119119
- Change the heap profile dump format to support per thread heap profiling,
120-
and enhance pprof with the --thread=<n> option. As a result, the bundled
121-
pprof must now be used rather than the upstream (gperftools) pprof.
120+
rename pprof to jeprof, and enhance it with the --thread=<n> option. As a
121+
result, the bundled jeprof must now be used rather than the upstream
122+
(gperftools) pprof.
122123
- Disable "opt.prof_final" by default, in order to avoid atexit(3), which can
123124
internally deadlock on some platforms.
124125
- Change the "arenas.nlruns" mallctl type from size_t to unsigned.

Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ endif
7373
LIBJEMALLOC := $(LIBPREFIX)jemalloc$(install_suffix)
7474

7575
# Lists of files.
76-
BINS := $(srcroot)bin/pprof $(objroot)bin/jemalloc-config $(objroot)bin/jemalloc.sh
76+
BINS := $(objroot)bin/jemalloc-config $(objroot)bin/jemalloc.sh $(objroot)bin/jeprof
7777
C_HDRS := $(objroot)include/jemalloc/jemalloc$(install_suffix).h
7878
C_SRCS := $(srcroot)src/jemalloc.c $(srcroot)src/arena.c \
7979
$(srcroot)src/atomic.c $(srcroot)src/base.c $(srcroot)src/bitmap.c \

bin/pprof renamed to bin/jeprof.in

Lines changed: 58 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,28 @@
4040
#
4141
# Examples:
4242
#
43-
# % tools/pprof "program" "profile"
43+
# % tools/jeprof "program" "profile"
4444
# Enters "interactive" mode
4545
#
46-
# % tools/pprof --text "program" "profile"
46+
# % tools/jeprof --text "program" "profile"
4747
# Generates one line per procedure
4848
#
49-
# % tools/pprof --gv "program" "profile"
49+
# % tools/jeprof --gv "program" "profile"
5050
# Generates annotated call-graph and displays via "gv"
5151
#
52-
# % tools/pprof --gv --focus=Mutex "program" "profile"
52+
# % tools/jeprof --gv --focus=Mutex "program" "profile"
5353
# Restrict to code paths that involve an entry that matches "Mutex"
5454
#
55-
# % tools/pprof --gv --focus=Mutex --ignore=string "program" "profile"
55+
# % tools/jeprof --gv --focus=Mutex --ignore=string "program" "profile"
5656
# Restrict to code paths that involve an entry that matches "Mutex"
5757
# and does not match "string"
5858
#
59-
# % tools/pprof --list=IBF_CheckDocid "program" "profile"
59+
# % tools/jeprof --list=IBF_CheckDocid "program" "profile"
6060
# Generates disassembly listing of all routines with at least one
6161
# sample that match the --list=<regexp> pattern. The listing is
6262
# annotated with the flat and cumulative sample counts at each line.
6363
#
64-
# % tools/pprof --disasm=IBF_CheckDocid "program" "profile"
64+
# % tools/jeprof --disasm=IBF_CheckDocid "program" "profile"
6565
# Generates disassembly listing of all routines with at least one
6666
# sample that match the --disasm=<regexp> pattern. The listing is
6767
# annotated with the flat and cumulative sample counts at each PC value.
@@ -72,10 +72,11 @@ use strict;
7272
use warnings;
7373
use Getopt::Long;
7474

75+
my $JEPROF_VERSION = "@jemalloc_version@";
7576
my $PPROF_VERSION = "2.0";
7677

7778
# These are the object tools we use which can come from a
78-
# user-specified location using --tools, from the PPROF_TOOLS
79+
# user-specified location using --tools, from the JEPROF_TOOLS
7980
# environment variable, or from the environment.
8081
my %obj_tool_map = (
8182
"objdump" => "objdump",
@@ -144,13 +145,13 @@ my $sep_address = undef;
144145
sub usage_string {
145146
return <<EOF;
146147
Usage:
147-
pprof [options] <program> <profiles>
148+
jeprof [options] <program> <profiles>
148149
<profiles> is a space separated list of profile names.
149-
pprof [options] <symbolized-profiles>
150+
jeprof [options] <symbolized-profiles>
150151
<symbolized-profiles> is a list of profile files where each file contains
151152
the necessary symbol mappings as well as profile data (likely generated
152153
with --raw).
153-
pprof [options] <profile>
154+
jeprof [options] <profile>
154155
<profile> is a remote form. Symbols are obtained from host:port$SYMBOL_PAGE
155156
156157
Each name can be:
@@ -161,9 +162,9 @@ pprof [options] <profile>
161162
$GROWTH_PAGE, $CONTENTION_PAGE, /pprof/wall,
162163
$CENSUSPROFILE_PAGE, or /pprof/filteredprofile.
163164
For instance:
164-
pprof http://myserver.com:80$HEAP_PAGE
165+
jeprof http://myserver.com:80$HEAP_PAGE
165166
If /<service> is omitted, the service defaults to $PROFILE_PAGE (cpu profiling).
166-
pprof --symbols <program>
167+
jeprof --symbols <program>
167168
Maps addresses to symbol names. In this mode, stdin should be a
168169
list of library mappings, in the same format as is found in the heap-
169170
and cpu-profile files (this loosely matches that of /proc/self/maps
@@ -202,7 +203,7 @@ Output type:
202203
--pdf Generate PDF to stdout
203204
--svg Generate SVG to stdout
204205
--gif Generate GIF to stdout
205-
--raw Generate symbolized pprof data (useful with remote fetch)
206+
--raw Generate symbolized jeprof data (useful with remote fetch)
206207
207208
Heap-Profile Options:
208209
--inuse_space Display in-use (mega)bytes [default]
@@ -236,42 +237,43 @@ Miscellaneous:
236237
--version Version information
237238
238239
Environment Variables:
239-
PPROF_TMPDIR Profiles directory. Defaults to \$HOME/pprof
240-
PPROF_TOOLS Prefix for object tools pathnames
240+
JEPROF_TMPDIR Profiles directory. Defaults to \$HOME/jeprof
241+
JEPROF_TOOLS Prefix for object tools pathnames
241242
242243
Examples:
243244
244-
pprof /bin/ls ls.prof
245+
jeprof /bin/ls ls.prof
245246
Enters "interactive" mode
246-
pprof --text /bin/ls ls.prof
247+
jeprof --text /bin/ls ls.prof
247248
Outputs one line per procedure
248-
pprof --web /bin/ls ls.prof
249+
jeprof --web /bin/ls ls.prof
249250
Displays annotated call-graph in web browser
250-
pprof --gv /bin/ls ls.prof
251+
jeprof --gv /bin/ls ls.prof
251252
Displays annotated call-graph via 'gv'
252-
pprof --gv --focus=Mutex /bin/ls ls.prof
253+
jeprof --gv --focus=Mutex /bin/ls ls.prof
253254
Restricts to code paths including a .*Mutex.* entry
254-
pprof --gv --focus=Mutex --ignore=string /bin/ls ls.prof
255+
jeprof --gv --focus=Mutex --ignore=string /bin/ls ls.prof
255256
Code paths including Mutex but not string
256-
pprof --list=getdir /bin/ls ls.prof
257+
jeprof --list=getdir /bin/ls ls.prof
257258
(Per-line) annotated source listing for getdir()
258-
pprof --disasm=getdir /bin/ls ls.prof
259+
jeprof --disasm=getdir /bin/ls ls.prof
259260
(Per-PC) annotated disassembly for getdir()
260261
261-
pprof http://localhost:1234/
262+
jeprof http://localhost:1234/
262263
Enters "interactive" mode
263-
pprof --text localhost:1234
264+
jeprof --text localhost:1234
264265
Outputs one line per procedure for localhost:1234
265-
pprof --raw localhost:1234 > ./local.raw
266-
pprof --text ./local.raw
266+
jeprof --raw localhost:1234 > ./local.raw
267+
jeprof --text ./local.raw
267268
Fetches a remote profile for later analysis and then
268269
analyzes it in text mode.
269270
EOF
270271
}
271272

272273
sub version_string {
273274
return <<EOF
274-
pprof (part of gperftools $PPROF_VERSION)
275+
jeprof (part of jemalloc $JEPROF_VERSION)
276+
based on pprof (part of gperftools $PPROF_VERSION)
275277
276278
Copyright 1998-2007 Google Inc.
277279
@@ -294,8 +296,8 @@ sub Init() {
294296
# Setup tmp-file name and handler to clean it up.
295297
# We do this in the very beginning so that we can use
296298
# error() and cleanup() function anytime here after.
297-
$main::tmpfile_sym = "/tmp/pprof$$.sym";
298-
$main::tmpfile_ps = "/tmp/pprof$$";
299+
$main::tmpfile_sym = "/tmp/jeprof$$.sym";
300+
$main::tmpfile_ps = "/tmp/jeprof$$";
299301
$main::next_tmpfile = 0;
300302
$SIG{'INT'} = \&sighandler;
301303

@@ -802,22 +804,22 @@ sub InteractiveMode {
802804
$| = 1; # Make output unbuffered for interactive mode
803805
my ($orig_profile, $symbols, $libs, $total) = @_;
804806

805-
print STDERR "Welcome to pprof! For help, type 'help'.\n";
807+
print STDERR "Welcome to jeprof! For help, type 'help'.\n";
806808

807809
# Use ReadLine if it's installed and input comes from a console.
808810
if ( -t STDIN &&
809811
!ReadlineMightFail() &&
810812
defined(eval {require Term::ReadLine}) ) {
811-
my $term = new Term::ReadLine 'pprof';
812-
while ( defined ($_ = $term->readline('(pprof) '))) {
813+
my $term = new Term::ReadLine 'jeprof';
814+
while ( defined ($_ = $term->readline('(jeprof) '))) {
813815
$term->addhistory($_) if /\S/;
814816
if (!InteractiveCommand($orig_profile, $symbols, $libs, $total, $_)) {
815817
last; # exit when we get an interactive command to quit
816818
}
817819
}
818820
} else { # don't have readline
819821
while (1) {
820-
print STDERR "(pprof) ";
822+
print STDERR "(jeprof) ";
821823
$_ = <STDIN>;
822824
last if ! defined $_ ;
823825
s/\r//g; # turn windows-looking lines into unix-looking lines
@@ -1010,7 +1012,7 @@ sub ProcessProfile {
10101012

10111013
sub InteractiveHelpMessage {
10121014
print STDERR <<ENDOFHELP;
1013-
Interactive pprof mode
1015+
Interactive jeprof mode
10141016
10151017
Commands:
10161018
gv
@@ -1053,7 +1055,7 @@ Commands:
10531055
Generates callgrind file. If no filename is given, kcachegrind is called.
10541056
10551057
help - This listing
1056-
quit or ^D - End pprof
1058+
quit or ^D - End jeprof
10571059
10581060
For commands that accept optional -ignore tags, samples where any routine in
10591061
the stack trace matches the regular expression in any of the -ignore
@@ -1498,7 +1500,7 @@ h1 {
14981500
}
14991501
</style>
15001502
<script type="text/javascript">
1501-
function pprof_toggle_asm(e) {
1503+
function jeprof_toggle_asm(e) {
15021504
var target;
15031505
if (!e) e = window.event;
15041506
if (e.target) target = e.target;
@@ -1767,7 +1769,7 @@ sub PrintSource {
17671769

17681770
if ($html) {
17691771
printf $output (
1770-
"<h1>%s</h1>%s\n<pre onClick=\"pprof_toggle_asm()\">\n" .
1772+
"<h1>%s</h1>%s\n<pre onClick=\"jeprof_toggle_asm()\">\n" .
17711773
"Total:%6s %6s (flat / cumulative %s)\n",
17721774
HtmlEscape(ShortFunctionName($routine)),
17731775
HtmlEscape(CleanFileName($filename)),
@@ -3433,7 +3435,7 @@ sub FetchDynamicProfile {
34333435
$profile_file .= $suffix;
34343436
}
34353437

3436-
my $profile_dir = $ENV{"PPROF_TMPDIR"} || ($ENV{HOME} . "/pprof");
3438+
my $profile_dir = $ENV{"JEPROF_TMPDIR"} || ($ENV{HOME} . "/jeprof");
34373439
if (! -d $profile_dir) {
34383440
mkdir($profile_dir)
34393441
|| die("Unable to create profile directory $profile_dir: $!\n");
@@ -3649,7 +3651,7 @@ BEGIN {
36493651
# Reads the top, 'header' section of a profile, and returns the last
36503652
# line of the header, commonly called a 'header line'. The header
36513653
# section of a profile consists of zero or more 'command' lines that
3652-
# are instructions to pprof, which pprof executes when reading the
3654+
# are instructions to jeprof, which jeprof executes when reading the
36533655
# header. All 'command' lines start with a %. After the command
36543656
# lines is the 'header line', which is a profile-specific line that
36553657
# indicates what type of profile it is, and perhaps other global
@@ -4256,10 +4258,10 @@ sub ReadSynchProfile {
42564258
} elsif ($variable eq "sampling period") {
42574259
$sampling_period = $value;
42584260
} elsif ($variable eq "ms since reset") {
4259-
# Currently nothing is done with this value in pprof
4261+
# Currently nothing is done with this value in jeprof
42604262
# So we just silently ignore it for now
42614263
} elsif ($variable eq "discarded samples") {
4262-
# Currently nothing is done with this value in pprof
4264+
# Currently nothing is done with this value in jeprof
42634265
# So we just silently ignore it for now
42644266
} else {
42654267
printf STDERR ("Ignoring unnknown variable in /contention output: " .
@@ -4565,7 +4567,7 @@ sub ParseLibraries {
45654567
}
45664568

45674569
# Add two hex addresses of length $address_length.
4568-
# Run pprof --test for unit test if this is changed.
4570+
# Run jeprof --test for unit test if this is changed.
45694571
sub AddressAdd {
45704572
my $addr1 = shift;
45714573
my $addr2 = shift;
@@ -4619,7 +4621,7 @@ sub AddressAdd {
46194621

46204622

46214623
# Subtract two hex addresses of length $address_length.
4622-
# Run pprof --test for unit test if this is changed.
4624+
# Run jeprof --test for unit test if this is changed.
46234625
sub AddressSub {
46244626
my $addr1 = shift;
46254627
my $addr2 = shift;
@@ -4671,7 +4673,7 @@ sub AddressSub {
46714673
}
46724674

46734675
# Increment a hex addresses of length $address_length.
4674-
# Run pprof --test for unit test if this is changed.
4676+
# Run jeprof --test for unit test if this is changed.
46754677
sub AddressInc {
46764678
my $addr = shift;
46774679
my $sum;
@@ -4989,7 +4991,7 @@ sub UnparseAddress {
49894991
# 32-bit or ELF 64-bit executable file. The location of the tools
49904992
# is determined by considering the following options in this order:
49914993
# 1) --tools option, if set
4992-
# 2) PPROF_TOOLS environment variable, if set
4994+
# 2) JEPROF_TOOLS environment variable, if set
49934995
# 3) the environment
49944996
sub ConfigureObjTools {
49954997
my $prog_file = shift;
@@ -5022,7 +5024,7 @@ sub ConfigureObjTools {
50225024
# For windows, we provide a version of nm and addr2line as part of
50235025
# the opensource release, which is capable of parsing
50245026
# Windows-style PDB executables. It should live in the path, or
5025-
# in the same directory as pprof.
5027+
# in the same directory as jeprof.
50265028
$obj_tool_map{"nm_pdb"} = "nm-pdb";
50275029
$obj_tool_map{"addr2line_pdb"} = "addr2line-pdb";
50285030
}
@@ -5041,20 +5043,20 @@ sub ConfigureObjTools {
50415043
}
50425044

50435045
# Returns the path of a caller-specified object tool. If --tools or
5044-
# PPROF_TOOLS are specified, then returns the full path to the tool
5046+
# JEPROF_TOOLS are specified, then returns the full path to the tool
50455047
# with that prefix. Otherwise, returns the path unmodified (which
50465048
# means we will look for it on PATH).
50475049
sub ConfigureTool {
50485050
my $tool = shift;
50495051
my $path;
50505052

5051-
# --tools (or $PPROF_TOOLS) is a comma separated list, where each
5053+
# --tools (or $JEPROF_TOOLS) is a comma separated list, where each
50525054
# item is either a) a pathname prefix, or b) a map of the form
50535055
# <tool>:<path>. First we look for an entry of type (b) for our
50545056
# tool. If one is found, we use it. Otherwise, we consider all the
50555057
# pathname prefixes in turn, until one yields an existing file. If
50565058
# none does, we use a default path.
5057-
my $tools = $main::opt_tools || $ENV{"PPROF_TOOLS"} || "";
5059+
my $tools = $main::opt_tools || $ENV{"JEPROF_TOOLS"} || "";
50585060
if ($tools =~ m/(,|^)\Q$tool\E:([^,]*)/) {
50595061
$path = $2;
50605062
# TODO(csilvers): sanity-check that $path exists? Hard if it's relative.
@@ -5068,11 +5070,11 @@ sub ConfigureTool {
50685070
}
50695071
if (!$path) {
50705072
error("No '$tool' found with prefix specified by " .
5071-
"--tools (or \$PPROF_TOOLS) '$tools'\n");
5073+
"--tools (or \$JEPROF_TOOLS) '$tools'\n");
50725074
}
50735075
} else {
50745076
# ... otherwise use the version that exists in the same directory as
5075-
# pprof. If there's nothing there, use $PATH.
5077+
# jeprof. If there's nothing there, use $PATH.
50765078
$0 =~ m,[^/]*$,; # this is everything after the last slash
50775079
my $dirname = $`; # this is everything up to and including the last slash
50785080
if (-x "$dirname$tool") {
@@ -5102,7 +5104,7 @@ sub cleanup {
51025104
unlink($main::tmpfile_sym);
51035105
unlink(keys %main::tempnames);
51045106

5105-
# We leave any collected profiles in $HOME/pprof in case the user wants
5107+
# We leave any collected profiles in $HOME/jeprof in case the user wants
51065108
# to look at them later. We print a message informing them of this.
51075109
if ((scalar(@main::profile_files) > 0) &&
51085110
defined($main::collected_profile)) {
@@ -5111,7 +5113,7 @@ sub cleanup {
51115113
}
51125114
print STDERR "If you want to investigate this profile further, you can do:\n";
51135115
print STDERR "\n";
5114-
print STDERR " pprof \\\n";
5116+
print STDERR " jeprof \\\n";
51155117
print STDERR " $main::prog \\\n";
51165118
print STDERR " $main::collected_profile\n";
51175119
print STDERR "\n";
@@ -5296,7 +5298,7 @@ sub GetProcedureBoundaries {
52965298
# The test vectors for AddressAdd/Sub/Inc are 8-16-nibble hex strings.
52975299
# To make them more readable, we add underscores at interesting places.
52985300
# This routine removes the underscores, producing the canonical representation
5299-
# used by pprof to represent addresses, particularly in the tested routines.
5301+
# used by jeprof to represent addresses, particularly in the tested routines.
53005302
sub CanonicalHex {
53015303
my $arg = shift;
53025304
return join '', (split '_',$arg);

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1607,7 +1607,7 @@ AC_CONFIG_HEADERS([$cfghdrs_tup])
16071607
dnl ============================================================================
16081608
dnl Generate outputs.
16091609

1610-
AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc-config bin/jemalloc.sh])
1610+
AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc-config bin/jemalloc.sh bin/jeprof])
16111611
AC_SUBST([cfgoutputs_in])
16121612
AC_SUBST([cfgoutputs_out])
16131613
AC_OUTPUT

0 commit comments

Comments
 (0)