Skip to content

Commit f70a254

Browse files
committed
Merge branch 'dev'
2 parents e02b83c + 09f8585 commit f70a254

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+4916
-2428
lines changed

COPYING

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Unless otherwise specified, files in the jemalloc source distribution are
22
subject to the following license:
33
--------------------------------------------------------------------------------
4-
Copyright (C) 2002-2015 Jason Evans <[email protected]>.
4+
Copyright (C) 2002-2016 Jason Evans <[email protected]>.
55
All rights reserved.
66
Copyright (C) 2007-2012 Mozilla Foundation. All rights reserved.
7-
Copyright (C) 2009-2015 Facebook, Inc. All rights reserved.
7+
Copyright (C) 2009-2016 Facebook, Inc. All rights reserved.
88

99
Redistribution and use in source and binary forms, with or without
1010
modification, are permitted provided that the following conditions are met:

ChangeLog

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,29 @@ brevity. Much more detail can be found in the git revision history:
44

55
https://github.com/jemalloc/jemalloc
66

7+
* 4.2.0 (May 12, 2016)
8+
9+
New features:
10+
- Add the arena.<i>.reset mallctl, which makes it possible to discard all of
11+
an arena's allocations in a single operation. (@jasone@)
12+
- Add the stats.retained and stats.arenas.<i>.retained statistics. (@jasone)
13+
- Add the --with-version configure option. (@jasone)
14+
- Support --with-lg-page values larger than actual page size. (@jasone)
15+
16+
Optimizations:
17+
- Use pairing heaps rather than red-black trees for various hot data
18+
structures. (@djwatson, @jasone)
19+
- Streamline fast paths of rtree operations. (@jasone)
20+
- Optimize the fast paths of calloc() and [m,d,sd]allocx(). (@jasone)
21+
- Decommit unused virtual memory if the OS does not overcommit. (@jasone)
22+
- Specify MAP_NORESERVE on Linux if [heuristic] overcommit is active, in order
23+
to avoid unfortunate interactions during fork(2). (@jasone)
24+
25+
Bug fixes:
26+
- Fix chunk accounting related to triggering gdump profiles. (@jasone)
27+
- Link against librt for clock_gettime(2) if glibc < 2.17. (@jasone)
28+
- Scale leak report summary according to sampling probability. (@jasone)
29+
730
* 4.1.1 (May 3, 2016)
831

932
This bugfix release resolves a variety of mostly minor issues, though the
@@ -21,7 +44,7 @@ brevity. Much more detail can be found in the git revision history:
2144
enabled and active. (@jasone)
2245
- Fix various chunk leaks in OOM code paths. (@jasone)
2346
- Fix malloc_stats_print() to print opt.narenas correctly. (@jasone)
24-
- Fix MSVC-specific build/test issues. (@rustyx, yuslepukhin)
47+
- Fix MSVC-specific build/test issues. (@rustyx, @yuslepukhin)
2548
- Fix a variety of test failures that were due to test fragility rather than
2649
core bugs. (@jasone)
2750

@@ -80,14 +103,14 @@ brevity. Much more detail can be found in the git revision history:
80103
Bug fixes:
81104
- Fix stats.cactive accounting regression. (@rustyx, @jasone)
82105
- Handle unaligned keys in hash(). This caused problems for some ARM systems.
83-
(@jasone, Christopher Ferris)
106+
(@jasone, @cferris1000)
84107
- Refactor arenas array. In addition to fixing a fork-related deadlock, this
85108
makes arena lookups faster and simpler. (@jasone)
86109
- Move retained memory allocation out of the default chunk allocation
87110
function, to a location that gets executed even if the application installs
88111
a custom chunk allocation function. This resolves a virtual memory leak.
89112
(@buchgr)
90-
- Fix a potential tsd cleanup leak. (Christopher Ferris, @jasone)
113+
- Fix a potential tsd cleanup leak. (@cferris1000, @jasone)
91114
- Fix run quantization. In practice this bug had no impact unless
92115
applications requested memory with alignment exceeding one page.
93116
(@jasone, @djwatson)

INSTALL

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ any of the following arguments (not a definitive list) to 'configure':
3535
will cause files to be installed into /usr/local/include, /usr/local/lib,
3636
and /usr/local/man.
3737

38+
--with-version=<major>.<minor>.<bugfix>-<nrev>-g<gid>
39+
Use the specified version string rather than trying to generate one (if in
40+
a git repository) or use existing the VERSION file (if present).
41+
3842
--with-rpath=<colon-separated-rpath>
3943
Embed one or more library paths, so that libjemalloc can find the libraries
4044
it is linked to. This works only on ELF-based systems.

Makefile.in

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ CFLAGS := @CFLAGS@
2828
LDFLAGS := @LDFLAGS@
2929
EXTRA_LDFLAGS := @EXTRA_LDFLAGS@
3030
LIBS := @LIBS@
31-
TESTLIBS := @TESTLIBS@
3231
RPATH_EXTRA := @RPATH_EXTRA@
3332
SO := @so@
3433
IMPORTLIB := @importlib@
@@ -103,7 +102,8 @@ C_SRCS := $(srcroot)src/jemalloc.c \
103102
$(srcroot)src/tcache.c \
104103
$(srcroot)src/ticker.c \
105104
$(srcroot)src/tsd.c \
106-
$(srcroot)src/util.c
105+
$(srcroot)src/util.c \
106+
$(srcroot)src/witness.c
107107
ifeq ($(enable_valgrind), 1)
108108
C_SRCS += $(srcroot)src/valgrind.c
109109
endif
@@ -134,7 +134,10 @@ C_TESTLIB_SRCS := $(srcroot)test/src/btalloc.c $(srcroot)test/src/btalloc_0.c \
134134
$(srcroot)test/src/SFMT.c $(srcroot)test/src/test.c \
135135
$(srcroot)test/src/thd.c $(srcroot)test/src/timer.c
136136
C_UTIL_INTEGRATION_SRCS := $(srcroot)src/nstime.c $(srcroot)src/util.c
137-
TESTS_UNIT := $(srcroot)test/unit/atomic.c \
137+
TESTS_UNIT := \
138+
$(srcroot)test/unit/a0.c \
139+
$(srcroot)test/unit/arena_reset.c \
140+
$(srcroot)test/unit/atomic.c \
138141
$(srcroot)test/unit/bitmap.c \
139142
$(srcroot)test/unit/ckh.c \
140143
$(srcroot)test/unit/decay.c \
@@ -148,6 +151,7 @@ TESTS_UNIT := $(srcroot)test/unit/atomic.c \
148151
$(srcroot)test/unit/math.c \
149152
$(srcroot)test/unit/mq.c \
150153
$(srcroot)test/unit/mtx.c \
154+
$(srcroot)test/unit/ph.c \
151155
$(srcroot)test/unit/prng.c \
152156
$(srcroot)test/unit/prof_accum.c \
153157
$(srcroot)test/unit/prof_active.c \
@@ -169,6 +173,7 @@ TESTS_UNIT := $(srcroot)test/unit/atomic.c \
169173
$(srcroot)test/unit/nstime.c \
170174
$(srcroot)test/unit/tsd.c \
171175
$(srcroot)test/unit/util.c \
176+
$(srcroot)test/unit/witness.c \
172177
$(srcroot)test/unit/zero.c
173178
TESTS_INTEGRATION := $(srcroot)test/integration/aligned_alloc.c \
174179
$(srcroot)test/integration/allocated.c \
@@ -290,15 +295,15 @@ $(STATIC_LIBS):
290295

291296
$(objroot)test/unit/%$(EXE): $(objroot)test/unit/%.$(O) $(TESTS_UNIT_LINK_OBJS) $(C_JET_OBJS) $(C_TESTLIB_UNIT_OBJS)
292297
@mkdir -p $(@D)
293-
$(CC) $(LDTARGET) $(filter %.$(O),$^) $(call RPATH,$(objroot)lib) $(LDFLAGS) $(filter-out -lm,$(LIBS)) -lm $(TESTLIBS) $(EXTRA_LDFLAGS)
298+
$(CC) $(LDTARGET) $(filter %.$(O),$^) $(call RPATH,$(objroot)lib) $(LDFLAGS) $(filter-out -lm,$(LIBS)) -lm $(EXTRA_LDFLAGS)
294299

295300
$(objroot)test/integration/%$(EXE): $(objroot)test/integration/%.$(O) $(C_TESTLIB_INTEGRATION_OBJS) $(C_UTIL_INTEGRATION_OBJS) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB)
296301
@mkdir -p $(@D)
297-
$(CC) $(LDTARGET) $(filter %.$(O),$^) $(call RPATH,$(objroot)lib) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB) $(LDFLAGS) $(filter-out -lm,$(filter -lpthread,$(LIBS))) -lm $(TESTLIBS) $(EXTRA_LDFLAGS)
302+
$(CC) $(LDTARGET) $(filter %.$(O),$^) $(call RPATH,$(objroot)lib) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB) $(LDFLAGS) $(filter-out -lm,$(filter -lpthread,$(LIBS))) -lm $(EXTRA_LDFLAGS)
298303

299304
$(objroot)test/stress/%$(EXE): $(objroot)test/stress/%.$(O) $(C_JET_OBJS) $(C_TESTLIB_STRESS_OBJS) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB)
300305
@mkdir -p $(@D)
301-
$(CC) $(LDTARGET) $(filter %.$(O),$^) $(call RPATH,$(objroot)lib) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB) $(LDFLAGS) $(filter-out -lm,$(LIBS)) -lm $(TESTLIBS) $(EXTRA_LDFLAGS)
306+
$(CC) $(LDTARGET) $(filter %.$(O),$^) $(call RPATH,$(objroot)lib) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB) $(LDFLAGS) $(filter-out -lm,$(LIBS)) -lm $(EXTRA_LDFLAGS)
302307

303308
build_lib_shared: $(DSOS)
304309
build_lib_static: $(STATIC_LIBS)

configure.ac

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ if test "x$CFLAGS" = "x" ; then
141141
JE_CFLAGS_APPEND([-Wall])
142142
JE_CFLAGS_APPEND([-Werror=declaration-after-statement])
143143
JE_CFLAGS_APPEND([-Wshorten-64-to-32])
144+
JE_CFLAGS_APPEND([-Wsign-compare])
144145
JE_CFLAGS_APPEND([-pipe])
145146
JE_CFLAGS_APPEND([-g3])
146147
elif test "x$je_cv_msvc" = "xyes" ; then
@@ -304,6 +305,7 @@ case "${host}" in
304305
*-*-freebsd*)
305306
CFLAGS="$CFLAGS"
306307
abi="elf"
308+
AC_DEFINE([JEMALLOC_SYSCTL_VM_OVERCOMMIT], [ ])
307309
AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
308310
force_lazy_lock="1"
309311
;;
@@ -328,6 +330,7 @@ case "${host}" in
328330
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
329331
abi="elf"
330332
AC_DEFINE([JEMALLOC_HAS_ALLOCA_H])
333+
AC_DEFINE([JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY], [ ])
331334
AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED], [ ])
332335
AC_DEFINE([JEMALLOC_THREADED_INIT], [ ])
333336
AC_DEFINE([JEMALLOC_USE_CXX_THROW], [ ])
@@ -1172,27 +1175,36 @@ dnl ============================================================================
11721175
dnl jemalloc configuration.
11731176
dnl
11741177

1175-
dnl Set VERSION if source directory is inside a git repository.
1176-
if test "x`test ! \"${srcroot}\" && cd \"${srcroot}\"; git rev-parse --is-inside-work-tree 2>/dev/null`" = "xtrue" ; then
1177-
dnl Pattern globs aren't powerful enough to match both single- and
1178-
dnl double-digit version numbers, so iterate over patterns to support up to
1179-
dnl version 99.99.99 without any accidental matches.
1180-
rm -f "${objroot}VERSION"
1181-
for pattern in ['[0-9].[0-9].[0-9]' '[0-9].[0-9].[0-9][0-9]' \
1182-
'[0-9].[0-9][0-9].[0-9]' '[0-9].[0-9][0-9].[0-9][0-9]' \
1183-
'[0-9][0-9].[0-9].[0-9]' '[0-9][0-9].[0-9].[0-9][0-9]' \
1184-
'[0-9][0-9].[0-9][0-9].[0-9]' \
1185-
'[0-9][0-9].[0-9][0-9].[0-9][0-9]']; do
1186-
if test ! -e "${objroot}VERSION" ; then
1187-
(test ! "${srcroot}" && cd "${srcroot}"; git describe --long --abbrev=40 --match="${pattern}") > "${objroot}VERSION.tmp" 2>/dev/null
1188-
if test $? -eq 0 ; then
1189-
mv "${objroot}VERSION.tmp" "${objroot}VERSION"
1190-
break
1191-
fi
1178+
AC_ARG_WITH([version],
1179+
[AS_HELP_STRING([--with-version=<major>.<minor>.<bugfix>-<nrev>-g<gid>],
1180+
[Version string])],
1181+
[
1182+
echo "${with_version}" | grep ['^[0-9]\+\.[0-9]\+\.[0-9]\+-[0-9]\+-g[0-9a-f]\+$'] 2>&1 1>/dev/null
1183+
if test $? -ne 0 ; then
1184+
AC_MSG_ERROR([${with_version} does not match <major>.<minor>.<bugfix>-<nrev>-g<gid>])
11921185
fi
1193-
done
1194-
fi
1195-
rm -f "${objroot}VERSION.tmp"
1186+
echo "$with_version" > "${objroot}VERSION"
1187+
], [
1188+
dnl Set VERSION if source directory is inside a git repository.
1189+
if test "x`test ! \"${srcroot}\" && cd \"${srcroot}\"; git rev-parse --is-inside-work-tree 2>/dev/null`" = "xtrue" ; then
1190+
dnl Pattern globs aren't powerful enough to match both single- and
1191+
dnl double-digit version numbers, so iterate over patterns to support up
1192+
dnl to version 99.99.99 without any accidental matches.
1193+
for pattern in ['[0-9].[0-9].[0-9]' '[0-9].[0-9].[0-9][0-9]' \
1194+
'[0-9].[0-9][0-9].[0-9]' '[0-9].[0-9][0-9].[0-9][0-9]' \
1195+
'[0-9][0-9].[0-9].[0-9]' '[0-9][0-9].[0-9].[0-9][0-9]' \
1196+
'[0-9][0-9].[0-9][0-9].[0-9]' \
1197+
'[0-9][0-9].[0-9][0-9].[0-9][0-9]']; do
1198+
(test ! "${srcroot}" && cd "${srcroot}"; git describe --long --abbrev=40 --match="${pattern}") > "${objroot}VERSION.tmp" 2>/dev/null
1199+
if test $? -eq 0 ; then
1200+
mv "${objroot}VERSION.tmp" "${objroot}VERSION"
1201+
break
1202+
fi
1203+
done
1204+
fi
1205+
rm -f "${objroot}VERSION.tmp"
1206+
])
1207+
11961208
if test ! -e "${objroot}VERSION" ; then
11971209
if test ! -e "${srcroot}VERSION" ; then
11981210
AC_MSG_RESULT(
@@ -1229,13 +1241,8 @@ fi
12291241

12301242
CPPFLAGS="$CPPFLAGS -D_REENTRANT"
12311243

1232-
dnl Check whether clock_gettime(2) is in libc or librt. This function is only
1233-
dnl used in test code, so save the result to TESTLIBS to avoid poluting LIBS.
1234-
SAVED_LIBS="${LIBS}"
1235-
LIBS=
1236-
AC_SEARCH_LIBS([clock_gettime], [rt], [TESTLIBS="${LIBS}"])
1237-
AC_SUBST([TESTLIBS])
1238-
LIBS="${SAVED_LIBS}"
1244+
dnl Check whether clock_gettime(2) is in libc or librt.
1245+
AC_SEARCH_LIBS([clock_gettime], [rt])
12391246

12401247
dnl Check if the GNU-specific secure_getenv function exists.
12411248
AC_CHECK_FUNC([secure_getenv],
@@ -1741,7 +1748,6 @@ AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}])
17411748
AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}])
17421749
AC_MSG_RESULT([EXTRA_LDFLAGS : ${EXTRA_LDFLAGS}])
17431750
AC_MSG_RESULT([LIBS : ${LIBS}])
1744-
AC_MSG_RESULT([TESTLIBS : ${TESTLIBS}])
17451751
AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}])
17461752
AC_MSG_RESULT([])
17471753
AC_MSG_RESULT([XSLTPROC : ${XSLTPROC}])

doc/jemalloc.xml.in

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,8 @@ for (i = 0; i < nbins; i++) {
540540
are smaller than four times the page size, large size classes are smaller
541541
than the chunk size (see the <link
542542
linkend="opt.lg_chunk"><mallctl>opt.lg_chunk</mallctl></link> option), and
543-
huge size classes extend from the chunk size up to one size class less than
544-
the full address space size.</para>
543+
huge size classes extend from the chunk size up to the largest size class
544+
that does not exceed <constant>PTRDIFF_MAX</constant>.</para>
545545

546546
<para>Allocations are packed tightly together, which can be an issue for
547547
multi-threaded applications. If you need to assure that allocations do not
@@ -659,7 +659,7 @@ for (i = 0; i < nbins; i++) {
659659
<entry>[1280 KiB, 1536 KiB, 1792 KiB]</entry>
660660
</row>
661661
<row>
662-
<entry morerows="6">Huge</entry>
662+
<entry morerows="8">Huge</entry>
663663
<entry>256 KiB</entry>
664664
<entry>[2 MiB]</entry>
665665
</row>
@@ -687,6 +687,14 @@ for (i = 0; i < nbins; i++) {
687687
<entry>...</entry>
688688
<entry>...</entry>
689689
</row>
690+
<row>
691+
<entry>512 PiB</entry>
692+
<entry>[2560 PiB, 3 EiB, 3584 PiB, 4 EiB]</entry>
693+
</row>
694+
<row>
695+
<entry>1 EiB</entry>
696+
<entry>[5 EiB, 6 EiB, 7 EiB]</entry>
697+
</row>
690698
</tbody>
691699
</tgroup>
692700
</table>
@@ -1550,6 +1558,23 @@ malloc_conf = "xmalloc:true";]]></programlisting>
15501558
details.</para></listitem>
15511559
</varlistentry>
15521560

1561+
<varlistentry id="arena.i.reset">
1562+
<term>
1563+
<mallctl>arena.&lt;i&gt;.reset</mallctl>
1564+
(<type>void</type>)
1565+
<literal>--</literal>
1566+
</term>
1567+
<listitem><para>Discard all of the arena's extant allocations. This
1568+
interface can only be used with arenas created via <link
1569+
linkend="arenas.extend"><mallctl>arenas.extend</mallctl></link>. None
1570+
of the arena's discarded/cached allocations may accessed afterward. As
1571+
part of this requirement, all thread caches which were used to
1572+
allocate/deallocate in conjunction with the arena must be flushed
1573+
beforehand. This interface cannot be used if running inside Valgrind,
1574+
nor if the <link linkend="opt.quarantine">quarantine</link> size is
1575+
non-zero.</para></listitem>
1576+
</varlistentry>
1577+
15531578
<varlistentry id="arena.i.dss">
15541579
<term>
15551580
<mallctl>arena.&lt;i&gt;.dss</mallctl>
@@ -2161,6 +2186,25 @@ typedef struct {
21612186
linkend="stats.resident"><mallctl>stats.resident</mallctl></link>.</para></listitem>
21622187
</varlistentry>
21632188

2189+
<varlistentry id="stats.retained">
2190+
<term>
2191+
<mallctl>stats.retained</mallctl>
2192+
(<type>size_t</type>)
2193+
<literal>r-</literal>
2194+
[<option>--enable-stats</option>]
2195+
</term>
2196+
<listitem><para>Total number of bytes in virtual memory mappings that
2197+
were retained rather than being returned to the operating system via
2198+
e.g. <citerefentry><refentrytitle>munmap</refentrytitle>
2199+
<manvolnum>2</manvolnum></citerefentry>. Retained virtual memory is
2200+
typically untouched, decommitted, or purged, so it has no strongly
2201+
associated physical memory (see <link
2202+
linkend="arena.i.chunk_hooks">chunk hooks</link> for details). Retained
2203+
memory is excluded from mapped memory statistics, e.g. <link
2204+
linkend="stats.mapped"><mallctl>stats.mapped</mallctl></link>.
2205+
</para></listitem>
2206+
</varlistentry>
2207+
21642208
<varlistentry id="stats.arenas.i.dss">
21652209
<term>
21662210
<mallctl>stats.arenas.&lt;i&gt;.dss</mallctl>
@@ -2241,6 +2285,18 @@ typedef struct {
22412285
<listitem><para>Number of mapped bytes.</para></listitem>
22422286
</varlistentry>
22432287

2288+
<varlistentry id="stats.arenas.i.retained">
2289+
<term>
2290+
<mallctl>stats.arenas.&lt;i&gt;.retained</mallctl>
2291+
(<type>size_t</type>)
2292+
<literal>r-</literal>
2293+
[<option>--enable-stats</option>]
2294+
</term>
2295+
<listitem><para>Number of retained bytes. See <link
2296+
linkend="stats.retained"><mallctl>stats.retained</mallctl></link> for
2297+
details.</para></listitem>
2298+
</varlistentry>
2299+
22442300
<varlistentry id="stats.arenas.i.metadata.mapped">
22452301
<term>
22462302
<mallctl>stats.arenas.&lt;i&gt;.metadata.mapped</mallctl>

0 commit comments

Comments
 (0)