mirror of
https://github.com/mjansson/rpmalloc.git
synced 2026-01-15 19:41:17 +01:00
adding option to disable thp on linux/android
This commit is contained in:
@@ -2095,6 +2095,11 @@ rpmalloc_initialize(rpmalloc_interface_t* memory_interface) {
|
||||
if (global_config.enable_huge_pages || global_config.page_size > (256 * 1024))
|
||||
global_config.disable_decommit = 1;
|
||||
|
||||
#if defined(__linux__) || defined(__ANDROID__)
|
||||
if (global_config.disable_thp)
|
||||
(void)prctl(PR_SET_THP_DISABLE, 1, 0, 0, 0);
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
fls_key = FlsAlloc(&rpmalloc_thread_destructor);
|
||||
#else
|
||||
|
||||
@@ -187,6 +187,13 @@ typedef struct rpmalloc_config_t {
|
||||
// when process exits, but if using rpmalloc in a dynamic library you might want to unmap
|
||||
// all pages when the dynamic library unloads to avoid process memory leaks and bloat.
|
||||
int unmap_on_finalize;
|
||||
#if defined(__linux__) || defined(__ANDROID__)
|
||||
///! Allows to disable the Transparent Huge Page feature on Linux on a process basis,
|
||||
/// rather than enabling/disabling system-wise (done via /sys/kernel/mm/transparent_hugepage/enabled).
|
||||
/// It can possibly improve performance and reduced allocation overhead in some contexts, albeit
|
||||
/// THP is usually enabled by default.
|
||||
int disable_thp;
|
||||
#endif
|
||||
} rpmalloc_config_t;
|
||||
|
||||
//! Initialize allocator
|
||||
|
||||
Reference in New Issue
Block a user