Skip to content

Commit 85eccf3

Browse files
committed
Merge branch 'master' into dev
2 parents 6ca454a + 1ebb74c commit 85eccf3

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed

doc/mimalloc-doc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,7 @@ typedef enum mi_option_e {
782782
mi_option_eager_region_commit, ///< Eagerly commit large (256MiB) memory regions (enabled by default, except on Windows)
783783
mi_option_large_os_pages, ///< Use large OS pages (2MiB in size) if possible
784784
mi_option_reserve_huge_os_pages, ///< The number of huge OS pages (1GiB in size) to reserve at the start of the program.
785+
mi_option_reserve_huge_os_pages_at, ///< Reserve huge OS pages at node N.
785786
mi_option_segment_cache, ///< The number of segments per thread to keep cached.
786787
mi_option_page_reset, ///< Reset page memory after \a mi_option_reset_delay milliseconds when it becomes free.
787788
mi_option_segment_reset, ///< Experimental
@@ -1053,6 +1054,8 @@ or via environment variables.
10531054
`MIMALLOC_EAGER_COMMIT_DELAY=N` (`N` is 1 by default) to delay the initial `N` segments (of 4MiB)
10541055
of a thread to not allocate in the huge OS pages; this prevents threads that are short lived
10551056
and allocate just a little to take up space in the huge OS page area (which cannot be reset).
1057+
- `MIMALLOC_RESERVE_HUGE_OS_PAGES_AT=N`: where N is the numa node. This reserves the huge pages at a specific numa node.
1058+
(`N` is -1 by default to reserve huge pages evenly among the given number of numa nodes (or use the available ones as detected))
10561059
10571060
Use caution when using `fork` in combination with either large or huge OS pages: on a fork, the OS uses copy-on-write
10581061
for all pages in the original process including the huge OS pages. When any memory is now written in that area, the

include/mimalloc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ typedef enum mi_option_e {
310310
mi_option_reset_decommits,
311311
mi_option_large_os_pages, // implies eager commit
312312
mi_option_reserve_huge_os_pages,
313+
mi_option_reserve_huge_os_pages_at,
313314
mi_option_reserve_os_memory,
314315
mi_option_segment_cache,
315316
mi_option_page_reset,

readme.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Latest stable tag: `v1.7.3` (2021-11-14).
1818
mimalloc is a drop-in replacement for `malloc` and can be used in other programs
1919
without code changes, for example, on dynamically linked ELF-based systems (Linux, BSD, etc.) you can use it as:
2020
```
21-
> LD_PRELOAD=/usr/bin/libmimalloc.so myprogram
21+
> LD_PRELOAD=/usr/lib/libmimalloc.so myprogram
2222
```
2323
It also has an easy way to override the default allocator in [Windows](#override_on_windows). Notable aspects of the design include:
2424

@@ -311,6 +311,8 @@ or via environment variables:
311311
`MIMALLOC_EAGER_COMMIT_DELAY=N` (`N` is 1 by default) to delay the initial `N` segments (of 4MiB)
312312
of a thread to not allocate in the huge OS pages; this prevents threads that are short lived
313313
and allocate just a little to take up space in the huge OS page area (which cannot be reset).
314+
- `MIMALLOC_RESERVE_HUGE_OS_PAGES_AT=N`: where N is the numa node. This reserves the huge pages at a specific numa node.
315+
(`N` is -1 by default to reserve huge pages evenly among the given number of numa nodes (or use the available ones as detected))
314316

315317
Use caution when using `fork` in combination with either large or huge OS pages: on a fork, the OS uses copy-on-write
316318
for all pages in the original process including the huge OS pages. When any memory is now written in that area, the

src/init.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,12 @@ void mi_process_init(void) mi_attr_noexcept {
504504

505505
if (mi_option_is_enabled(mi_option_reserve_huge_os_pages)) {
506506
size_t pages = mi_option_get(mi_option_reserve_huge_os_pages);
507-
mi_reserve_huge_os_pages_interleave(pages, 0, pages*500);
507+
long reserve_at = mi_option_get(mi_option_reserve_huge_os_pages_at);
508+
if (reserve_at != -1) {
509+
mi_reserve_huge_os_pages_at(pages, reserve_at, pages*500);
510+
} else {
511+
mi_reserve_huge_os_pages_interleave(pages, 0, pages*500);
512+
}
508513
}
509514
if (mi_option_is_enabled(mi_option_reserve_os_memory)) {
510515
long ksize = mi_option_get(mi_option_reserve_os_memory);

src/options.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ static mi_option_desc_t options[_mi_option_last] =
7676
#endif
7777
{ 0, UNINIT, MI_OPTION(large_os_pages) }, // use large OS pages, use only with eager commit to prevent fragmentation of VMA's
7878
{ 0, UNINIT, MI_OPTION(reserve_huge_os_pages) }, // per 1GiB huge pages
79+
{ -1, UNINIT, MI_OPTION(reserve_huge_os_pages_at) }, // reserve huge pages at node N
7980
{ 0, UNINIT, MI_OPTION(reserve_os_memory) },
8081
{ 0, UNINIT, MI_OPTION(segment_cache) }, // cache N segments per thread
8182
{ 1, UNINIT, MI_OPTION(page_reset) }, // reset page memory on free

0 commit comments

Comments
 (0)