Go to file
gnzlbg 08260a6b94 Add experimental API: smallocx_return_t smallocx(size, flags)
---

Motivation:

This new experimental memory-allocaction API returns a pointer to
the allocation as well as the usable size of the allocated memory
region.

The `s` in `smallocx` stands for `sized`-`mallocx`, attempting to
convey that this API returns the size of the allocated memory region.

It should allow C++ P0901r0 [0] and Rust Alloc::alloc_excess to make
use of it.

The main purpose of these APIs is to improve telemetry. It is more accurate
to register `smallocx(size, flags)` than `smallocx(nallocx(size), flags)`,
for example. The latter will always line up perfectly with the existing
size classes, causing a loss of telemetry information about the internal
fragmentation induced by potentially poor size-classes choices.

Instrumenting `nallocx` does not help much since user code can cache its
result and use it repeatedly.

---

Implementation:

The implementation adds a new `usize` option to `static_opts_s` and an `usize`
variable to `dynamic_opts_s`. These are then used to cache the result of
`sz_index2size` and similar functions in the code paths in which they are
unconditionally invoked. In the code-paths in which these functions are not
unconditionally invoked, `smallocx` calls, as opposed to `mallocx`, these
functions explicitly.

---

[0]: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0901r0.html
2018-10-17 07:12:28 -07:00
bin Filter out "void *newImpl" in prof output. 2017-08-08 12:28:29 -07:00
build-aux Update config.{guess,sub} from upstream. 2016-11-10 15:08:32 -08:00
doc Add stats for the size of extent_avail heap 2018-08-02 10:16:06 -07:00
include Add experimental API: smallocx_return_t smallocx(size, flags) 2018-10-17 07:12:28 -07:00
m4 jemalloc cpp new/delete bindings 2016-12-12 18:36:06 -08:00
msvc Add sc.c to the MSVC project 2018-09-04 12:58:05 -07:00
scripts Add valgrind build bots to CI 2018-08-13 10:59:20 -07:00
src Add experimental API: smallocx_return_t smallocx(size, flags) 2018-10-17 07:12:28 -07:00
test Add hook microbenchmark. 2018-08-09 13:16:54 -07:00
.appveyor.yml Revert "CI: Remove "catgets" dependency on appveyor." 2018-03-15 13:58:42 -07:00
.autom4te.cfg Disable autom4te cache. 2014-09-02 17:49:29 -07:00
.gitattributes fix git handling of newlines on windows 2014-05-07 18:48:39 -04:00
.gitignore Kill size_classes.sh. 2018-07-12 20:53:06 -07:00
.travis.yml Add valgrind build bots to CI 2018-08-13 10:59:20 -07:00
autogen.sh Move repo contents in jemalloc/ to top level. 2011-03-31 20:36:17 -07:00
ChangeLog Update ChangeLog for 5.1.0. 2018-05-08 12:06:34 -07:00
config.stamp.in Move repo contents in jemalloc/ to top level. 2011-03-31 20:36:17 -07:00
configure.ac Add experimental API: smallocx_return_t smallocx(size, flags) 2018-10-17 07:12:28 -07:00
COPYING Update copyright dates. 2018-05-03 15:31:42 -07:00
INSTALL.md Remove the --with-lg-page-sizes configure option. 2018-07-12 20:53:06 -07:00
jemalloc.pc.in Reformat the version number in jemalloc.pc.in. 2018-05-07 20:12:03 -07:00
Makefile.in Add hook microbenchmark. 2018-08-09 13:16:54 -07:00
README Update project URL. 2016-09-12 11:56:24 -07:00
run_tests.sh Introduce scripts to run all possible tests 2017-01-30 17:51:57 -08:00
TUNING.md Add TUNING.md. 2018-05-03 12:52:52 -07:00

jemalloc is a general purpose malloc(3) implementation that emphasizes
fragmentation avoidance and scalable concurrency support.  jemalloc first came
into use as the FreeBSD libc allocator in 2005, and since then it has found its
way into numerous applications that rely on its predictable behavior.  In 2010
jemalloc development efforts broadened to include developer support features
such as heap profiling and extensive monitoring/tuning hooks.  Modern jemalloc
releases continue to be integrated back into FreeBSD, and therefore versatility
remains critical.  Ongoing development efforts trend toward making jemalloc
among the best allocators for a broad range of demanding applications, and
eliminating/mitigating weaknesses that have practical repercussions for real
world applications.

The COPYING file contains copyright and licensing information.

The INSTALL file contains information on how to configure, build, and install
jemalloc.

The ChangeLog file contains a brief summary of changes for each release.

URL: http://jemalloc.net/