• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

benchmark/H03-Mar-2021-560379

docs/H03-May-2022-340311

m4/H03-Mar-2021-10,7249,566

packages/H03-Mar-2021-717454

src/H03-May-2022-63,65338,632

vsprojects/H03-Mar-2021-4,6314,630

AUTHORSH A D14-Feb-202135 31

COPYINGH A D10-Aug-20141.4 KiB2925

ChangeLogH A D03-Mar-2021438.8 KiB14,43511,019

ChangeLog.oldH A D14-Feb-202133.7 KiB647569

INSTALLH A D14-Feb-202123.7 KiB565439

Makefile.amH A D03-May-202268.4 KiB1,5091,031

Makefile.inH A D03-Mar-2021683.9 KiB8,2897,397

NEWSH A D03-Mar-202142.8 KiB1,194824

READMEH A D14-Feb-202110.9 KiB280211

TODOH A D28-Nov-20171.6 KiB4836

aclocal.m4H A D03-Mar-202143 KiB1,1821,074

compileH A D03-Mar-20217.2 KiB349259

config.guessH A D03-Mar-202143.2 KiB1,4811,288

config.subH A D03-Mar-202135.3 KiB1,8021,661

configureH A D03-Mar-2021685 KiB22,67519,123

configure.acH A D03-Mar-202128 KiB658586

depcompH A D03-Mar-202123 KiB792502

gperftools.slnH A D14-Feb-202125.4 KiB308307

install-shH A D03-Mar-202115 KiB542352

libtoolH A D03-Mar-2021340.2 KiB11,9128,270

ltmain.shH A D03-Mar-2021319.6 KiB11,2528,044

missingH A D03-Mar-20216.7 KiB216143

pprof-symbolizeH A D14-Feb-2021174.1 KiB5,5814,212

test-driverH A D03-Mar-20214.6 KiB15188

README

1gperftools
2----------
3(originally Google Performance Tools)
4
5The fastest malloc we’ve seen; works particularly well with threads
6and STL. Also: thread-friendly heap-checker, heap-profiler, and
7cpu-profiler.
8
9
10OVERVIEW
11---------
12
13gperftools is a collection of a high-performance multi-threaded
14malloc() implementation, plus some pretty nifty performance analysis
15tools.
16
17gperftools is distributed under the terms of the BSD License. Join our
18mailing list at gperftools@googlegroups.com for updates:
19https://groups.google.com/forum/#!forum/gperftools
20
21gperftools was original home for pprof program. But do note that
22original pprof (which is still included with gperftools) is now
23deprecated in favor of golang version at https://github.com/google/pprof
24
25
26TCMALLOC
27--------
28Just link in -ltcmalloc or -ltcmalloc_minimal to get the advantages of
29tcmalloc -- a replacement for malloc and new.  See below for some
30environment variables you can use with tcmalloc, as well.
31
32tcmalloc functionality is available on all systems we've tested; see
33INSTALL for more details.  See README_windows.txt for instructions on
34using tcmalloc on Windows.
35
36when compiling.  gcc makes some optimizations assuming it is using its
37own, built-in malloc; that assumption obviously isn't true with
38tcmalloc.  In practice, we haven't seen any problems with this, but
39the expected risk is highest for users who register their own malloc
40hooks with tcmalloc (using gperftools/malloc_hook.h).  The risk is
41lowest for folks who use tcmalloc_minimal (or, of course, who pass in
42the above flags :-) ).
43
44
45HEAP PROFILER
46-------------
47See docs/heapprofile.html for information about how to use tcmalloc's
48heap profiler and analyze its output.
49
50As a quick-start, do the following after installing this package:
51
521) Link your executable with -ltcmalloc
532) Run your executable with the HEAPPROFILE environment var set:
54     $ HEAPPROFILE=/tmp/heapprof <path/to/binary> [binary args]
553) Run pprof to analyze the heap usage
56     $ pprof <path/to/binary> /tmp/heapprof.0045.heap  # run 'ls' to see options
57     $ pprof --gv <path/to/binary> /tmp/heapprof.0045.heap
58
59You can also use LD_PRELOAD to heap-profile an executable that you
60didn't compile.
61
62There are other environment variables, besides HEAPPROFILE, you can
63set to adjust the heap-profiler behavior; c.f. "ENVIRONMENT VARIABLES"
64below.
65
66The heap profiler is available on all unix-based systems we've tested;
67see INSTALL for more details.  It is not currently available on Windows.
68
69
70HEAP CHECKER
71------------
72See docs/heap_checker.html for information about how to use tcmalloc's
73heap checker.
74
75In order to catch all heap leaks, tcmalloc must be linked *last* into
76your executable.  The heap checker may mischaracterize some memory
77accesses in libraries listed after it on the link line.  For instance,
78it may report these libraries as leaking memory when they're not.
79(See the source code for more details.)
80
81Here's a quick-start for how to use:
82
83As a quick-start, do the following after installing this package:
84
851) Link your executable with -ltcmalloc
862) Run your executable with the HEAPCHECK environment var set:
87     $ HEAPCHECK=1 <path/to/binary> [binary args]
88
89Other values for HEAPCHECK: normal (equivalent to "1"), strict, draconian
90
91You can also use LD_PRELOAD to heap-check an executable that you
92didn't compile.
93
94The heap checker is only available on Linux at this time; see INSTALL
95for more details.
96
97
98CPU PROFILER
99------------
100See docs/cpuprofile.html for information about how to use the CPU
101profiler and analyze its output.
102
103As a quick-start, do the following after installing this package:
104
1051) Link your executable with -lprofiler
1062) Run your executable with the CPUPROFILE environment var set:
107     $ CPUPROFILE=/tmp/prof.out <path/to/binary> [binary args]
1083) Run pprof to analyze the CPU usage
109     $ pprof <path/to/binary> /tmp/prof.out      # -pg-like text output
110     $ pprof --gv <path/to/binary> /tmp/prof.out # really cool graphical output
111
112There are other environment variables, besides CPUPROFILE, you can set
113to adjust the cpu-profiler behavior; cf "ENVIRONMENT VARIABLES" below.
114
115The CPU profiler is available on all unix-based systems we've tested;
116see INSTALL for more details.  It is not currently available on Windows.
117
118NOTE: CPU profiling doesn't work after fork (unless you immediately
119      do an exec()-like call afterwards).  Furthermore, if you do
120      fork, and the child calls exit(), it may corrupt the profile
121      data.  You can use _exit() to work around this.  We hope to have
122      a fix for both problems in the next release of perftools
123      (hopefully perftools 1.2).
124
125
126EVERYTHING IN ONE
127-----------------
128If you want the CPU profiler, heap profiler, and heap leak-checker to
129all be available for your application, you can do:
130   gcc -o myapp ... -lprofiler -ltcmalloc
131
132However, if you have a reason to use the static versions of the
133library, this two-library linking won't work:
134   gcc -o myapp ... /usr/lib/libprofiler.a /usr/lib/libtcmalloc.a  # errors!
135
136Instead, use the special libtcmalloc_and_profiler library, which we
137make for just this purpose:
138   gcc -o myapp ... /usr/lib/libtcmalloc_and_profiler.a
139
140
141CONFIGURATION OPTIONS
142---------------------
143For advanced users, there are several flags you can pass to
144'./configure' that tweak tcmalloc performance.  (These are in addition
145to the environment variables you can set at runtime to affect
146tcmalloc, described below.)  See the INSTALL file for details.
147
148
149ENVIRONMENT VARIABLES
150---------------------
151The cpu profiler, heap checker, and heap profiler will lie dormant,
152using no memory or CPU, until you turn them on.  (Thus, there's no
153harm in linking -lprofiler into every application, and also -ltcmalloc
154assuming you're ok using the non-libc malloc library.)
155
156The easiest way to turn them on is by setting the appropriate
157environment variables.  We have several variables that let you
158enable/disable features as well as tweak parameters.
159
160Here are some of the most important variables:
161
162HEAPPROFILE=<pre> -- turns on heap profiling and dumps data using this prefix
163HEAPCHECK=<type>  -- turns on heap checking with strictness 'type'
164CPUPROFILE=<file> -- turns on cpu profiling and dumps data to this file.
165PROFILESELECTED=1 -- if set, cpu-profiler will only profile regions of code
166                     surrounded with ProfilerEnable()/ProfilerDisable().
167CPUPROFILE_FREQUENCY=x-- how many interrupts/second the cpu-profiler samples.
168
169PERFTOOLS_VERBOSE=<level> -- the higher level, the more messages malloc emits
170MALLOCSTATS=<level>    -- prints memory-use stats at program-exit
171
172For a full list of variables, see the documentation pages:
173   docs/cpuprofile.html
174   docs/heapprofile.html
175   docs/heap_checker.html
176
177
178COMPILING ON NON-LINUX SYSTEMS
179------------------------------
180
181Perftools was developed and tested on x86 Linux systems, and it works
182in its full generality only on those systems.  However, we've
183successfully ported much of the tcmalloc library to FreeBSD, Solaris
184x86, and Darwin (Mac OS X) x86 and ppc; and we've ported the basic
185functionality in tcmalloc_minimal to Windows.  See INSTALL for details.
186See README_windows.txt for details on the Windows port.
187
188
189PERFORMANCE
190-----------
191
192If you're interested in some third-party comparisons of tcmalloc to
193other malloc libraries, here are a few web pages that have been
194brought to our attention.  The first discusses the effect of using
195various malloc libraries on OpenLDAP.  The second compares tcmalloc to
196win32's malloc.
197  http://www.highlandsun.com/hyc/malloc/
198  http://gaiacrtn.free.fr/articles/win32perftools.html
199
200It's possible to build tcmalloc in a way that trades off faster
201performance (particularly for deletes) at the cost of more memory
202fragmentation (that is, more unusable memory on your system).  See the
203INSTALL file for details.
204
205
206OLD SYSTEM ISSUES
207-----------------
208
209When compiling perftools on some old systems, like RedHat 8, you may
210get an error like this:
211    ___tls_get_addr: symbol not found
212
213This means that you have a system where some parts are updated enough
214to support Thread Local Storage, but others are not.  The perftools
215configure script can't always detect this kind of case, leading to
216that error.  To fix it, just comment out (or delete) the line
217   #define HAVE_TLS 1
218in your config.h file before building.
219
220
22164-BIT ISSUES
222-------------
223
224There are two issues that can cause program hangs or crashes on x86_64
22564-bit systems, which use the libunwind library to get stack-traces.
226Neither issue should affect the core tcmalloc library; they both
227affect the perftools tools such as cpu-profiler, heap-checker, and
228heap-profiler.
229
2301) Some libc's -- at least glibc 2.4 on x86_64 -- have a bug where the
231libc function dl_iterate_phdr() acquires its locks in the wrong
232order.  This bug should not affect tcmalloc, but may cause occasional
233deadlock with the cpu-profiler, heap-profiler, and heap-checker.
234Its likeliness increases the more dlopen() commands an executable has.
235Most executables don't have any, though several library routines like
236getgrgid() call dlopen() behind the scenes.
237
2382) On x86-64 64-bit systems, while tcmalloc itself works fine, the
239cpu-profiler tool is unreliable: it will sometimes work, but sometimes
240cause a segfault.  I'll explain the problem first, and then some
241workarounds.
242
243Note that this only affects the cpu-profiler, which is a
244gperftools feature you must turn on manually by setting the
245CPUPROFILE environment variable.  If you do not turn on cpu-profiling,
246you shouldn't see any crashes due to perftools.
247
248The gory details: The underlying problem is in the backtrace()
249function, which is a built-in function in libc.
250Backtracing is fairly straightforward in the normal case, but can run
251into problems when having to backtrace across a signal frame.
252Unfortunately, the cpu-profiler uses signals in order to register a
253profiling event, so every backtrace that the profiler does crosses a
254signal frame.
255
256In our experience, the only time there is trouble is when the signal
257fires in the middle of pthread_mutex_lock.  pthread_mutex_lock is
258called quite a bit from system libraries, particularly at program
259startup and when creating a new thread.
260
261The solution: The dwarf debugging format has support for 'cfi
262annotations', which make it easy to recognize a signal frame.  Some OS
263distributions, such as Fedora and gentoo 2007.0, already have added
264cfi annotations to their libc.  A future version of libunwind should
265recognize these annotations; these systems should not see any
266crashes.
267
268Workarounds: If you see problems with crashes when running the
269cpu-profiler, consider inserting ProfilerStart()/ProfilerStop() into
270your code, rather than setting CPUPROFILE.  This will profile only
271those sections of the codebase.  Though we haven't done much testing,
272in theory this should reduce the chance of crashes by limiting the
273signal generation to only a small part of the codebase.  Ideally, you
274would not use ProfilerStart()/ProfilerStop() around code that spawns
275new threads, or is otherwise likely to cause a call to
276pthread_mutex_lock!
277
278---
27917 May 2011
280