From b19bdfac872f2f5fd03ada55fc27f07f01e2a826 Mon Sep 17 00:00:00 2001 From: Shivam7-1 <55046031+Shivam7-1@users.noreply.github.com> Date: Sat, 5 Sep 2020 08:01:09 +0530 Subject: [PATCH 1/9] Updated readme.md --- readme.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index daf57f39..4c1c1c40 100644 --- a/readme.md +++ b/readme.md @@ -215,7 +215,7 @@ completely and redirect all calls to the _mimalloc_ library instead . ## Environment Options You can set further options either programmatically (using [`mi_option_set`](https://microsoft.github.io/mimalloc/group__options.html)), -or via environment variables. +or via environment variables: - `MIMALLOC_SHOW_STATS=1`: show statistics when the program terminates. - `MIMALLOC_VERBOSE=1`: show verbose messages. @@ -265,11 +265,11 @@ _mimalloc_ can be build in secure mode by using the `-DMI_SECURE=ON` flags in `c to make mimalloc more robust against exploits. In particular: - All internal mimalloc pages are surrounded by guard pages and the heap metadata is behind a guard page as well (so a buffer overflow - exploit cannot reach into the metadata), + exploit cannot reach into the metadata). - All free list pointers are [encoded](https://github.com/microsoft/mimalloc/blob/783e3377f79ee82af43a0793910a9f2d01ac7863/include/mimalloc-internal.h#L396) - with per-page keys which is used both to prevent overwrites with a known pointer, as well as to detect heap corruption, -- Double free's are detected (and ignored), + with per-page keys which is used both to prevent overwrites with a known pointer, as well as to detect heap corruption. +- Double free's are detected (and ignored). - The free lists are initialized in a random order and allocation randomly chooses between extension and reuse within a page to mitigate against attacks that rely on a predicable allocation order. Similarly, the larger heap blocks allocated by mimalloc from the OS are also address randomized. From 568d6e532b65c6441e5ea8ee873e68055a2f5841 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Thu, 10 Sep 2020 18:49:19 +0000 Subject: [PATCH 2/9] Haiku build fix. Haiku does not provide page faults statistics only system wide. --- src/stats.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/stats.c b/src/stats.c index 842e2009..099dea7f 100644 --- a/src/stats.c +++ b/src/stats.c @@ -497,7 +497,9 @@ static void mi_stat_process_info(mi_msecs_t* utime, mi_msecs_t* stime, size_t* c getrusage(RUSAGE_SELF, &rusage); *utime = timeval_secs(&rusage.ru_utime); *stime = timeval_secs(&rusage.ru_stime); +#if !defined(__HAIKU__) *page_faults = rusage.ru_majflt; +#endif // estimate commit using our stats *peak_commit = (size_t)(mi_atomic_loadi64_relaxed((_Atomic(int64_t)*)&_mi_stats_main.committed.peak)); *current_commit = (size_t)(mi_atomic_loadi64_relaxed((_Atomic(int64_t)*)&_mi_stats_main.committed.current)); From f5e3cca74ebf74b0894dfc5ff472098f9d31d144 Mon Sep 17 00:00:00 2001 From: Igor Kostenko Date: Mon, 14 Sep 2020 11:13:03 +0100 Subject: [PATCH 3/9] Do not require to specify version for cmake find_package --- cmake/mimalloc-config-version.cmake | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cmake/mimalloc-config-version.cmake b/cmake/mimalloc-config-version.cmake index 6454d91f..edffeea1 100644 --- a/cmake/mimalloc-config-version.cmake +++ b/cmake/mimalloc-config-version.cmake @@ -3,14 +3,16 @@ set(mi_version_minor 6) set(mi_version ${mi_version_major}.${mi_version_minor}) set(PACKAGE_VERSION ${mi_version}) -if("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL "${mi_version_major}") - if ("${PACKAGE_FIND_VERSION_MINOR}" EQUAL "${mi_version_minor}") - set(PACKAGE_VERSION_EXACT TRUE) - elseif("${PACKAGE_FIND_VERSION_MINOR}" LESS "${mi_version_minor}") - set(PACKAGE_VERSION_COMPATIBLE TRUE) +if(PACKAGE_FIND_VERSION_MAJOR) + if("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL "${mi_version_major}") + if ("${PACKAGE_FIND_VERSION_MINOR}" EQUAL "${mi_version_minor}") + set(PACKAGE_VERSION_EXACT TRUE) + elseif("${PACKAGE_FIND_VERSION_MINOR}" LESS "${mi_version_minor}") + set(PACKAGE_VERSION_COMPATIBLE TRUE) + else() + set(PACKAGE_VERSION_UNSUITABLE TRUE) + endif() else() set(PACKAGE_VERSION_UNSUITABLE TRUE) endif() -else() - set(PACKAGE_VERSION_UNSUITABLE TRUE) endif() From d6ca70c9cce75d382bfe9be3409f58dd688edb61 Mon Sep 17 00:00:00 2001 From: Daan Date: Mon, 14 Sep 2020 08:30:49 -0700 Subject: [PATCH 4/9] Update readme.md Clarify the distinctive idea of mimalloc as free-list multi-sharding --- readme.md | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/readme.md b/readme.md index daf57f39..96565fde 100644 --- a/readme.md +++ b/readme.md @@ -18,19 +18,27 @@ without code changes, for example, on dynamically linked ELF-based systems (Linu ``` > LD_PRELOAD=/usr/bin/libmimalloc.so myprogram ``` -It also has an easy way to override the allocator in [Windows](#override_on_windows). Notable aspects of the design include: +It also has an easy way to override the default allocator in [Windows](#override_on_windows). Notable aspects of the design include: -- __small and consistent__: the library is about 6k LOC using simple and +- __small and consistent__: the library is about 8k LOC using simple and consistent data structures. This makes it very suitable to integrate and adapt in other projects. For runtime systems it provides hooks for a monotonic _heartbeat_ and deferred freeing (for bounded worst-case times with reference counting). -- __free list sharding__: the big idea: instead of one big free list (per size class) we have - many smaller lists per memory "page" which both reduces fragmentation - and increases locality -- +- __free list sharding__: instead of one big free list (per size class) we have + many smaller lists per "mimalloc page" which reduces fragmentation and + increases locality -- things that are allocated close in time get allocated close in memory. - (A memory "page" in _mimalloc_ contains blocks of one size class and is - usually 64KiB on a 64-bit system). + (A mimalloc page contains blocks of one size class and is usually 64KiB on a 64-bit system). +- __free list multi-sharding__: the big idea! Not only do we shard the free list + per mimalloc page, but for each page we have multiple free lists. In particular, there + is one list for thread-local `free` operatinons, and another separate one for concurrent `free` + operations. Free-ing from another thread can now be a single CAS without needing + a sophisticated data structure to coordinate between threads. Since there will be + thousands of separate free lists, contention is naturally distributed over the heap, + and the chance of contending on a single location will be low -- this is quite + similar to randomized algorithms like skip lists where adding + a random oracle removes the need for a more complex algorithm. - __eager page reset__: when a "page" becomes empty (with increased chance due to free list sharding) the memory is marked to the OS as unused ("reset" or "purged") reducing (real) memory pressure and fragmentation, especially in long running From 0df0c17f5abf555bddbf2842ec700395667bd8b6 Mon Sep 17 00:00:00 2001 From: Daan Date: Mon, 14 Sep 2020 08:31:20 -0700 Subject: [PATCH 5/9] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 96565fde..ca94e7f0 100644 --- a/readme.md +++ b/readme.md @@ -36,7 +36,7 @@ It also has an easy way to override the default allocator in [Windows](#override operations. Free-ing from another thread can now be a single CAS without needing a sophisticated data structure to coordinate between threads. Since there will be thousands of separate free lists, contention is naturally distributed over the heap, - and the chance of contending on a single location will be low -- this is quite + and the chance of contending on a single location will be low -- this is quite similar to randomized algorithms like skip lists where adding a random oracle removes the need for a more complex algorithm. - __eager page reset__: when a "page" becomes empty (with increased chance From 64a3d24dcdf702aa7c1fc36c03e6cc8e8d4a49c2 Mon Sep 17 00:00:00 2001 From: daan Date: Wed, 23 Sep 2020 20:00:23 -0700 Subject: [PATCH 6/9] bump version to 1.6.5 --- include/mimalloc.h | 2 +- readme.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mimalloc.h b/include/mimalloc.h index 5b3d13ed..e09f7d36 100644 --- a/include/mimalloc.h +++ b/include/mimalloc.h @@ -8,7 +8,7 @@ terms of the MIT license. A copy of the license can be found in the file #ifndef MIMALLOC_H #define MIMALLOC_H -#define MI_MALLOC_VERSION 166 // major + 2 digits minor +#define MI_MALLOC_VERSION 165 // major + 2 digits minor // ------------------------------------------------------ // Compiler specific attributes diff --git a/readme.md b/readme.md index daf57f39..d8c94119 100644 --- a/readme.md +++ b/readme.md @@ -11,7 +11,7 @@ mimalloc (pronounced "me-malloc") is a general purpose allocator with excellent [performance](#performance) characteristics. Initially developed by Daan Leijen for the run-time systems of the [Koka](https://github.com/koka-lang/koka) and [Lean](https://github.com/leanprover/lean) languages. -Latest release:`v1.6.4` (2020-08-06). +Latest release:`v1.6.5` (2020-09-24). It is a drop-in replacement for `malloc` and can be used in other programs without code changes, for example, on dynamically linked ELF-based systems (Linux, BSD, etc.) you can use it as: From 1adec58c835ac7deedb3ee74818af1a46329da28 Mon Sep 17 00:00:00 2001 From: daan Date: Wed, 23 Sep 2020 20:02:24 -0700 Subject: [PATCH 7/9] fix spelling --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 3ce29538..a1a4b759 100644 --- a/readme.md +++ b/readme.md @@ -32,9 +32,9 @@ It also has an easy way to override the default allocator in [Windows](#override (A mimalloc page contains blocks of one size class and is usually 64KiB on a 64-bit system). - __free list multi-sharding__: the big idea! Not only do we shard the free list per mimalloc page, but for each page we have multiple free lists. In particular, there - is one list for thread-local `free` operatinons, and another separate one for concurrent `free` + is one list for thread-local `free` operations, and another one for concurrent `free` operations. Free-ing from another thread can now be a single CAS without needing - a sophisticated data structure to coordinate between threads. Since there will be + sophisticated coordination between threads. Since there will be thousands of separate free lists, contention is naturally distributed over the heap, and the chance of contending on a single location will be low -- this is quite similar to randomized algorithms like skip lists where adding From 4d3ddcfc51e04ca0583a9aaa895ba529a603f27b Mon Sep 17 00:00:00 2001 From: daan Date: Wed, 23 Sep 2020 20:37:17 -0700 Subject: [PATCH 8/9] update readme for upcoming release; add acknowledgements --- readme.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index a1a4b759..5e9407ad 100644 --- a/readme.md +++ b/readme.md @@ -63,8 +63,18 @@ You can read more on the design of _mimalloc_ in the [technical report](https:// Enjoy! +### Branches + +* `master`: latest stable release. +* `dev`: latest development branch. +* `dev-slice`: experimental branch with a different way of managing mimalloc pages that tends + to use less memory than plain mimalloc with similar performance. Give it a try and please + report any significant performance improvement or degradation. + ### Releases +* 2020-09-24, `v1.6.5`: stable release 1.6: using standard C atomics, passing tsan testing, improved + handling of out-of-memory and failed commits, add `mi_process_info` api call. * 2020-08-06, `v1.6.4`: stable release 1.6: improved error recovery in low-memory situations, support for IllumOS and Haiku, NUMA support for Vista/XP, improved NUMA detection for AMD Ryzen, ubsan support. * 2020-05-05, `v1.6.3`: stable release 1.6: improved behavior in out-of-memory situations, improved malloc zones on macOS, @@ -92,9 +102,16 @@ free list encoding](https://github.com/microsoft/mimalloc/blob/783e3377f79ee82af Special thanks to: -* Jason Gibson (@jasongibson) for exhaustive testing on large workloads and server environments and finding complex bugs in (early versions of) `mimalloc`. +* Mary Feofanova (@mary3000), Evgeniy Moiseenko, and Manuel Pöter (@mpoeter) for making mimalloc TSAN checkable, and finding + memory model bugs using the [genMC] model checker. +* Weipeng Liu (@pongba), Zhuowei Li, Junhua Wang, and Jakub Szymanski, for their early support of mimalloc and deployment + at large scale services, leading to many improvements in the mimalloc algorithms for large workloads. +* Jason Gibson (@jasongibson) for exhaustive testing on large scale workloads and server environments, and finding complex bugs + in (early versions of) `mimalloc`. * Manuel Pöter (@mpoeter) and Sam Gross (@colesbury) for finding an ABA concurrency issue in abandoned segment reclamation. +[genMC]: https://plv.mpi-sws.org/genmc/ + # Building ## Windows From 41683071c1395340b4243fb6b4f1133966c13f71 Mon Sep 17 00:00:00 2001 From: daan Date: Thu, 24 Sep 2020 09:05:01 -0700 Subject: [PATCH 9/9] update readme --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 5e9407ad..3dcefb53 100644 --- a/readme.md +++ b/readme.md @@ -68,13 +68,13 @@ Enjoy! * `master`: latest stable release. * `dev`: latest development branch. * `dev-slice`: experimental branch with a different way of managing mimalloc pages that tends - to use less memory than plain mimalloc with similar performance. Give it a try and please + to use less memory than regular mimalloc with similar performance. Give it a try and please report any significant performance improvement or degradation. ### Releases * 2020-09-24, `v1.6.5`: stable release 1.6: using standard C atomics, passing tsan testing, improved - handling of out-of-memory and failed commits, add `mi_process_info` api call. + handling of failing to commit on Windows, add `mi_process_info` api call. * 2020-08-06, `v1.6.4`: stable release 1.6: improved error recovery in low-memory situations, support for IllumOS and Haiku, NUMA support for Vista/XP, improved NUMA detection for AMD Ryzen, ubsan support. * 2020-05-05, `v1.6.3`: stable release 1.6: improved behavior in out-of-memory situations, improved malloc zones on macOS,