merge from dev
This commit is contained in:
commit
99141497ee
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,5 +1,5 @@
|
|||||||
set(mi_version_major 1)
|
set(mi_version_major 1)
|
||||||
set(mi_version_minor 0)
|
set(mi_version_minor 1)
|
||||||
set(mi_version ${mi_version_major}.${mi_version_minor})
|
set(mi_version ${mi_version_major}.${mi_version_minor})
|
||||||
|
|
||||||
set(PACKAGE_VERSION ${mi_version})
|
set(PACKAGE_VERSION ${mi_version})
|
||||||
|
@ -8,7 +8,7 @@ terms of the MIT license. A copy of the license can be found in the file
|
|||||||
#ifndef MIMALLOC_H
|
#ifndef MIMALLOC_H
|
||||||
#define MIMALLOC_H
|
#define MIMALLOC_H
|
||||||
|
|
||||||
#define MI_MALLOC_VERSION 100 // major + 2 digits minor
|
#define MI_MALLOC_VERSION 110 // major + 2 digits minor
|
||||||
|
|
||||||
// ------------------------------------------------------
|
// ------------------------------------------------------
|
||||||
// Compiler specific attributes
|
// Compiler specific attributes
|
||||||
|
@ -20,7 +20,7 @@ without code changes, for example, on dynamically linked ELF-based systems (Linu
|
|||||||
|
|
||||||
Notable aspects of the design include:
|
Notable aspects of the design include:
|
||||||
|
|
||||||
- __small and consistent__: the library is less than 3500 LOC using simple and
|
- __small and consistent__: the library is about 6k LOC using simple and
|
||||||
consistent data structures. This makes it very suitable
|
consistent data structures. This makes it very suitable
|
||||||
to integrate and adapt in other projects. For runtime systems it
|
to integrate and adapt in other projects. For runtime systems it
|
||||||
provides hooks for a monotonic _heartbeat_ and deferred freeing (for
|
provides hooks for a monotonic _heartbeat_ and deferred freeing (for
|
||||||
@ -42,7 +42,7 @@ Notable aspects of the design include:
|
|||||||
- __first-class heaps__: efficiently create and use multiple heaps to allocate across different regions.
|
- __first-class heaps__: efficiently create and use multiple heaps to allocate across different regions.
|
||||||
A heap can be destroyed at once instead of deallocating each object separately.
|
A heap can be destroyed at once instead of deallocating each object separately.
|
||||||
- __bounded__: it does not suffer from _blowup_ \[1\], has bounded worst-case allocation
|
- __bounded__: it does not suffer from _blowup_ \[1\], has bounded worst-case allocation
|
||||||
times (_wcat_), bounded space overhead (~0.2% meta-data, with at most 16.7% waste in allocation sizes),
|
times (_wcat_), bounded space overhead (~0.2% meta-data, with at most 12.5% waste in allocation sizes),
|
||||||
and has no internal points of contention using only atomic operations.
|
and has no internal points of contention using only atomic operations.
|
||||||
- __fast__: In our benchmarks (see [below](#performance)),
|
- __fast__: In our benchmarks (see [below](#performance)),
|
||||||
_mimalloc_ always outperforms all other leading allocators (_jemalloc_, _tcmalloc_, _Hoard_, etc),
|
_mimalloc_ always outperforms all other leading allocators (_jemalloc_, _tcmalloc_, _Hoard_, etc),
|
||||||
@ -56,8 +56,9 @@ Enjoy!
|
|||||||
|
|
||||||
### Releases
|
### Releases
|
||||||
|
|
||||||
* 2019-08-10, `v1.0.6`: pre-release 6: various performance improvements.
|
* 2019-10-07, `v1.1.0`: stable release 1.1.
|
||||||
* 2019-09-01, `v1.0.8`: pre-release 8: more robust windows dynamic overriding, initial huge page support.
|
* 2019-09-01, `v1.0.8`: pre-release 8: more robust windows dynamic overriding, initial huge page support.
|
||||||
|
* 2019-08-10, `v1.0.6`: pre-release 6: various performance improvements.
|
||||||
|
|
||||||
# Building
|
# Building
|
||||||
|
|
||||||
|
@ -150,10 +150,10 @@ static _Atomic(uintptr_t) out_len;
|
|||||||
|
|
||||||
static void mi_out_buf(const char* msg) {
|
static void mi_out_buf(const char* msg) {
|
||||||
if (msg==NULL) return;
|
if (msg==NULL) return;
|
||||||
|
if (mi_atomic_read_relaxed(&out_len)>=MAX_OUT_BUF) return;
|
||||||
size_t n = strlen(msg);
|
size_t n = strlen(msg);
|
||||||
if (n==0) return;
|
if (n==0) return;
|
||||||
// claim
|
// claim space
|
||||||
if (mi_atomic_read_relaxed(&out_len)>=MAX_OUT_BUF) return;
|
|
||||||
uintptr_t start = mi_atomic_addu(&out_len, n);
|
uintptr_t start = mi_atomic_addu(&out_len, n);
|
||||||
if (start >= MAX_OUT_BUF) return;
|
if (start >= MAX_OUT_BUF) return;
|
||||||
// check bound
|
// check bound
|
||||||
@ -163,17 +163,17 @@ static void mi_out_buf(const char* msg) {
|
|||||||
memcpy(&out_buf[start], msg, n);
|
memcpy(&out_buf[start], msg, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mi_out_buf_contents(mi_output_fun* out) {
|
static void mi_out_buf_flush(mi_output_fun* out) {
|
||||||
if (out==NULL) return;
|
if (out==NULL) return;
|
||||||
// claim all
|
// claim all (no more output will be added after this point)
|
||||||
size_t count = mi_atomic_addu(&out_len, MAX_OUT_BUF);
|
size_t count = mi_atomic_addu(&out_len, MAX_OUT_BUF);
|
||||||
// and output it
|
// and output the current contents
|
||||||
if (count>MAX_OUT_BUF) count = MAX_OUT_BUF;
|
if (count>MAX_OUT_BUF) count = MAX_OUT_BUF;
|
||||||
out_buf[count] = 0;
|
out_buf[count] = 0;
|
||||||
out(out_buf);
|
out(out_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The initial default output outputs to stderr and the delayed buffer.
|
// The initial default output, outputs to stderr and the delayed output buffer.
|
||||||
static void mi_out_buf_stderr(const char* msg) {
|
static void mi_out_buf_stderr(const char* msg) {
|
||||||
mi_out_stderr(msg);
|
mi_out_stderr(msg);
|
||||||
mi_out_buf(msg);
|
mi_out_buf(msg);
|
||||||
@ -195,13 +195,13 @@ static mi_output_fun* mi_out_get_default(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void mi_register_output(mi_output_fun* out) mi_attr_noexcept {
|
void mi_register_output(mi_output_fun* out) mi_attr_noexcept {
|
||||||
mi_out_default = (out == NULL ? &mi_out_stderr : out);
|
mi_out_default = (out == NULL ? &mi_out_stderr : out); // stop using the delayed output buffer
|
||||||
if (out!=NULL) mi_out_buf_contents(out);
|
if (out!=NULL) mi_out_buf_flush(out); // output the delayed output now
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------------------
|
// --------------------------------------------------------
|
||||||
// Messages
|
// Messages, all end up calling `_mi_fputs`.
|
||||||
// --------------------------------------------------------
|
// --------------------------------------------------------
|
||||||
#define MAX_ERROR_COUNT (10)
|
#define MAX_ERROR_COUNT (10)
|
||||||
static volatile _Atomic(uintptr_t) error_count; // = 0; // when MAX_ERROR_COUNT stop emitting errors and warnings
|
static volatile _Atomic(uintptr_t) error_count; // = 0; // when MAX_ERROR_COUNT stop emitting errors and warnings
|
||||||
|
Loading…
Reference in New Issue
Block a user