server-skynet-source-3rd-je.../include/jemalloc
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
..
internal Add experimental API: smallocx_return_t smallocx(size, flags) 2018-10-17 07:12:28 -07:00
jemalloc_defs.h.in Detect LG_SIZEOF_PTR depending on MSVC platform target 2016-02-20 10:50:24 -08:00
jemalloc_macros.h.in Replace tabs following #define with spaces. 2017-01-20 21:45:53 -08:00
jemalloc_mangle.sh jemalloc_mangle.sh: set sh in strict mode 2017-12-11 23:35:20 -08:00
jemalloc_protos.h.in Add experimental API: smallocx_return_t smallocx(size, flags) 2018-10-17 07:12:28 -07:00
jemalloc_rename.sh Fix name mangling for stress tests. 2014-01-16 17:38:01 -08:00
jemalloc_typedefs.h.in Add experimental API: smallocx_return_t smallocx(size, flags) 2018-10-17 07:12:28 -07:00
jemalloc.sh Replace tabs following #define with spaces. 2017-01-20 21:45:53 -08:00