2009-06-26 09:06:48 +08:00
|
|
|
Building and installing jemalloc can be as simple as typing the following while
|
|
|
|
in the root directory of the source tree:
|
|
|
|
|
|
|
|
./configure
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
|
|
|
|
=== Advanced configuration =====================================================
|
|
|
|
|
|
|
|
The 'configure' script supports numerous options that allow control of which
|
|
|
|
functionality is enabled, where jemalloc is installed, etc. Optionally, pass
|
|
|
|
any of the following arguments (not a definitive list) to 'configure':
|
|
|
|
|
|
|
|
--help
|
|
|
|
Print a definitive list of options.
|
|
|
|
|
|
|
|
--prefix=<install-root-dir>
|
|
|
|
Set the base directory in which to install. For example:
|
|
|
|
|
|
|
|
./configure --prefix=/usr/local
|
|
|
|
|
|
|
|
will cause files to be installed into /usr/local/include, /usr/local/lib,
|
|
|
|
and /usr/local/man.
|
|
|
|
|
|
|
|
--with-rpath=<colon-separated-rpath>
|
2009-12-29 16:09:15 +08:00
|
|
|
Embed one or more library paths, so that libjemalloc can find the libraries
|
|
|
|
it is linked to. This works only on ELF-based systems.
|
2009-06-26 09:06:48 +08:00
|
|
|
|
2009-12-29 16:09:15 +08:00
|
|
|
--with-jemalloc-prefix=<prefix>
|
2010-10-24 09:37:06 +08:00
|
|
|
Prefix all public APIs with <prefix>. For example, if <prefix> is
|
|
|
|
"prefix_", the API changes like the following occur:
|
|
|
|
|
|
|
|
malloc() --> prefix_malloc()
|
|
|
|
malloc_conf --> prefix_malloc_conf
|
|
|
|
/etc/malloc.conf --> /etc/prefix_malloc.conf
|
|
|
|
MALLOC_CONF --> PREFIX_MALLOC_CONF
|
|
|
|
|
2010-10-25 07:18:29 +08:00
|
|
|
This makes it possible to use jemalloc at the same time as the system
|
|
|
|
allocator, or even to use multiple copies of jemalloc simultaneously.
|
2009-12-29 16:09:15 +08:00
|
|
|
|
2010-09-06 01:35:13 +08:00
|
|
|
By default, the prefix is "", except on OS X, where it is "je_". On OS X,
|
|
|
|
jemalloc overlays the default malloc zone, but makes no attempt to actually
|
|
|
|
replace the "malloc", "calloc", etc. symbols.
|
|
|
|
|
2010-01-17 17:49:20 +08:00
|
|
|
--with-install-suffix=<suffix>
|
|
|
|
Append <suffix> to the base name of all installed files, such that multiple
|
|
|
|
versions of jemalloc can coexist in the same installation directory. For
|
|
|
|
example, libjemalloc.so.0 becomes libjemalloc<suffix>.so.0.
|
|
|
|
|
2010-09-21 10:20:48 +08:00
|
|
|
--enable-cc-silence
|
|
|
|
Enable code that silences unuseful compiler warnings. This is helpful when
|
|
|
|
trying to tell serious warnings from those due to compiler limitations, but
|
|
|
|
it potentially incurs a performance penalty.
|
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
--enable-debug
|
|
|
|
Enable assertions and validation code. This incurs a substantial
|
|
|
|
performance hit, but is very useful during application development.
|
|
|
|
|
|
|
|
--enable-stats
|
2010-10-25 07:18:29 +08:00
|
|
|
Enable statistics gathering functionality. See the "opt.stats_print"
|
|
|
|
option documentation for usage details.
|
2009-06-26 09:06:48 +08:00
|
|
|
|
2010-02-11 02:37:56 +08:00
|
|
|
--enable-prof
|
2010-10-25 07:18:29 +08:00
|
|
|
Enable heap profiling and leak detection functionality. See the "opt.prof"
|
|
|
|
option documention for usage details.
|
2010-02-11 02:37:56 +08:00
|
|
|
|
2010-02-11 10:15:53 +08:00
|
|
|
--disable-prof-libgcc
|
|
|
|
Disable the use of libgcc's backtracing functionality. Ordinarily, libgcc's
|
|
|
|
backtracing functionality is superior to the alternatives, but it may fail
|
|
|
|
to capture backtraces on some systems.
|
|
|
|
|
2010-02-11 02:37:56 +08:00
|
|
|
--enable-prof-libunwind
|
|
|
|
Use the libunwind library (http://www.nongnu.org/libunwind/) for stack
|
2010-02-11 10:15:53 +08:00
|
|
|
backtracing. libunwind is quite slow, but it tends to work across a wider
|
|
|
|
variety of system configurations than the default backtracing code, which is
|
|
|
|
based on libgcc functionality or gcc intrinsics.
|
2010-02-11 02:37:56 +08:00
|
|
|
|
2010-03-03 06:12:58 +08:00
|
|
|
--with-static-libunwind=<libunwind.a>
|
|
|
|
Statically link against the specified libunwind.a rather than dynamically
|
|
|
|
linking with -lunwind.
|
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
--disable-tiny
|
|
|
|
Disable tiny (sub-quantum-sized) object support. Technically it is not
|
|
|
|
legal for a malloc implementation to allocate objects with less than
|
|
|
|
quantum alignment (8 or 16 bytes, depending on architecture), but in
|
2009-06-27 07:34:13 +08:00
|
|
|
practice it never causes any problems if, for example, 4-byte allocations
|
2009-06-26 09:06:48 +08:00
|
|
|
are 4-byte-aligned.
|
|
|
|
|
2009-12-29 16:09:15 +08:00
|
|
|
--disable-tcache
|
2010-03-18 07:27:39 +08:00
|
|
|
Disable thread-specific caches for small objects. Objects are cached and
|
2010-10-25 07:18:29 +08:00
|
|
|
released in bulk, thus reducing the total number of mutex operations. See
|
|
|
|
the "opt.tcache" option for suage details.
|
2009-06-26 09:06:48 +08:00
|
|
|
|
2010-01-24 18:53:40 +08:00
|
|
|
--enable-swap
|
|
|
|
Enable mmap()ed swap file support. When this feature is built in, it is
|
|
|
|
possible to specify one or more files that act as backing store. This
|
|
|
|
effectively allows for per application swap files.
|
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
--enable-dss
|
|
|
|
Enable support for page allocation/deallocation via sbrk(2), in addition to
|
|
|
|
mmap(2).
|
|
|
|
|
|
|
|
--enable-fill
|
2010-10-25 07:18:29 +08:00
|
|
|
Enable support for junk/zero filling of memory. See the "opt.junk"/
|
|
|
|
"opt.zero" option documentation for usage details.
|
2009-06-26 09:06:48 +08:00
|
|
|
|
|
|
|
--enable-xmalloc
|
|
|
|
Enable support for optional immediate termination due to out-of-memory
|
|
|
|
errors, as is commonly implemented by "xmalloc" wrapper function for malloc.
|
2010-10-25 07:18:29 +08:00
|
|
|
See the "opt.xmalloc" option documentation for usage details.
|
2009-06-26 09:06:48 +08:00
|
|
|
|
|
|
|
--enable-sysv
|
|
|
|
Enable support for System V semantics, wherein malloc(0) returns NULL
|
2010-10-25 07:18:29 +08:00
|
|
|
rather than a minimal allocation. See the "opt.sysv" option documentation
|
|
|
|
for usage details.
|
2009-06-26 09:06:48 +08:00
|
|
|
|
|
|
|
--enable-dynamic-page-shift
|
|
|
|
Under most conditions, the system page size never changes (usually 4KiB or
|
|
|
|
8KiB, depending on architecture and configuration), and unless this option
|
|
|
|
is enabled, jemalloc assumes that page size can safely be determined during
|
|
|
|
configuration and hard-coded. Enabling dynamic page size determination has
|
|
|
|
a measurable impact on performance, since the compiler is forced to load
|
|
|
|
the page size from memory rather than embedding immediate values.
|
|
|
|
|
|
|
|
--disable-lazy-lock
|
|
|
|
Disable code that wraps pthread_create() to detect when an application
|
|
|
|
switches from single-threaded to multi-threaded mode, so that it can avoid
|
|
|
|
mutex locking/unlocking operations while in single-threaded mode. In
|
|
|
|
practice, this feature usually has little impact on performance unless
|
2009-12-29 16:09:15 +08:00
|
|
|
thread-specific caching is disabled.
|
2009-06-26 09:06:48 +08:00
|
|
|
|
2010-01-18 06:06:20 +08:00
|
|
|
--disable-tls
|
|
|
|
Disable thread-local storage (TLS), which allows for fast access to
|
|
|
|
thread-local variables via the __thread keyword. If TLS is available,
|
2010-04-12 10:02:43 +08:00
|
|
|
jemalloc uses it for several purposes. Note that disabling TLS implies
|
2010-01-18 06:06:20 +08:00
|
|
|
--disable-tcache.
|
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
The following environment variables (not a definitive list) impact configure's
|
|
|
|
behavior:
|
|
|
|
|
|
|
|
CFLAGS="?"
|
|
|
|
Pass these flags to the compiler. You probably shouldn't define this unless
|
|
|
|
you know what you are doing. (Use EXTRA_CFLAGS instead.)
|
|
|
|
|
|
|
|
EXTRA_CFLAGS="?"
|
|
|
|
Append these flags to CFLAGS. This makes it possible to add flags such as
|
|
|
|
-Werror, while allowing the configure script to determine what other flags
|
|
|
|
are appropriate for the specified configuration.
|
|
|
|
|
|
|
|
The configure script specifically checks whether an optimization flag (-O*)
|
|
|
|
is specified in EXTRA_CFLAGS, and refrains from specifying an optimization
|
|
|
|
level if it finds that one has already been specified.
|
|
|
|
|
|
|
|
CPPFLAGS="?"
|
|
|
|
Pass these flags to the C preprocessor. Note that CFLAGS is not passed to
|
|
|
|
'cpp' when 'configure' is looking for include files, so you must use
|
|
|
|
CPPFLAGS instead if you need to help 'configure' find header files.
|
|
|
|
|
|
|
|
LD_LIBRARY_PATH="?"
|
|
|
|
'ld' uses this colon-separated list to find libraries.
|
|
|
|
|
|
|
|
LDFLAGS="?"
|
|
|
|
Pass these flags when linking.
|
|
|
|
|
|
|
|
PATH="?"
|
|
|
|
'configure' uses this to find programs.
|
|
|
|
|
|
|
|
=== Advanced compilation =======================================================
|
|
|
|
|
2010-03-04 07:48:20 +08:00
|
|
|
To install only parts of jemalloc, use the following targets:
|
2009-06-26 09:06:48 +08:00
|
|
|
|
2010-04-12 10:02:43 +08:00
|
|
|
install_bin
|
2010-03-04 07:48:20 +08:00
|
|
|
install_include
|
|
|
|
install_lib
|
|
|
|
install_man
|
2009-06-26 09:06:48 +08:00
|
|
|
|
|
|
|
To clean up build results to varying degrees, use the following make targets:
|
|
|
|
|
|
|
|
clean
|
|
|
|
distclean
|
|
|
|
relclean
|
|
|
|
|
|
|
|
=== Advanced installation ======================================================
|
|
|
|
|
|
|
|
Optionally, define make variables when invoking make, including (not
|
|
|
|
exclusively):
|
|
|
|
|
|
|
|
INCLUDEDIR="?"
|
|
|
|
Use this as the installation prefix for header files.
|
|
|
|
|
|
|
|
LIBDIR="?"
|
|
|
|
Use this as the installation prefix for libraries.
|
|
|
|
|
|
|
|
MANDIR="?"
|
|
|
|
Use this as the installation prefix for man pages.
|
|
|
|
|
2010-03-04 07:48:20 +08:00
|
|
|
DESTDIR="?"
|
|
|
|
Prepend DESTDIR to INCLUDEDIR, LIBDIR, and MANDIR. This is useful when
|
|
|
|
installing to a different path than was specified via --prefix.
|
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
CC="?"
|
|
|
|
Use this to invoke the C compiler.
|
|
|
|
|
|
|
|
CFLAGS="?"
|
|
|
|
Pass these flags to the compiler.
|
|
|
|
|
|
|
|
CPPFLAGS="?"
|
|
|
|
Pass these flags to the C preprocessor.
|
|
|
|
|
|
|
|
LDFLAGS="?"
|
|
|
|
Pass these flags when linking.
|
|
|
|
|
|
|
|
PATH="?"
|
|
|
|
Use this to search for programs used during configuration and building.
|
|
|
|
|
|
|
|
=== Development ================================================================
|
|
|
|
|
|
|
|
If you intend to make non-trivial changes to jemalloc, use the 'autogen.sh'
|
|
|
|
script rather than 'configure'. This re-generates 'configure', enables
|
|
|
|
configuration dependency rules, and enables re-generation of automatically
|
|
|
|
generated source files.
|
|
|
|
|
|
|
|
The build system supports using an object directory separate from the source
|
|
|
|
tree. For example, you can create an 'obj' directory, and from within that
|
|
|
|
directory, issue configuration and build commands:
|
|
|
|
|
|
|
|
autoconf
|
|
|
|
mkdir obj
|
|
|
|
cd obj
|
|
|
|
../configure --enable-autogen
|
|
|
|
make
|
2010-09-12 13:47:39 +08:00
|
|
|
|
|
|
|
=== Documentation ==============================================================
|
|
|
|
|
|
|
|
The manual page that the configure script generates can be manually formatted
|
2010-10-25 07:48:52 +08:00
|
|
|
prior to installation via any of the following commands:
|
2010-09-12 13:47:39 +08:00
|
|
|
|
2010-10-25 07:48:52 +08:00
|
|
|
nroff -man -man-ext -t doc/jemalloc.3
|
|
|
|
|
|
|
|
groff -man -man-ext -t -Tps doc/jemalloc.3 | ps2pdf - doc/jemalloc.3.pdf
|
|
|
|
|
|
|
|
(cd doc; groff -man -man-ext -t -Thtml jemalloc.3 > jemalloc.3.html)
|