From 10dfa07e361b6a8b488a9263440bd69e64ae67ff Mon Sep 17 00:00:00 2001 From: Eugene Kuznetsov Date: Tue, 16 Jan 2024 16:37:40 +0100 Subject: [PATCH] Linux: Use huge pages in jemalloc to speed up allocations Enable huge pages for jemalloc. This requests the Linux kernel to use huge (2 MB) pages for large allocations. This has the effect of speeding up first accesses to those allocations, and possibly also speeds up future accesses by reducing TLB faults. By default, 4 KB pages are used unless the user enables huge pages through a kernel parameter or an obscure sysfs setting. For Cycles benchmarks, this gives about a 5% CPU rendering performance improvement. It likely also improves performance in other areas of Blender. Pull Request: https://projects.blender.org/blender/blender/pulls/116663 --- intern/guardedalloc/intern/mallocn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/guardedalloc/intern/mallocn.c b/intern/guardedalloc/intern/mallocn.c index 3c5524b07ac..adc39f8eb6d 100644 --- a/intern/guardedalloc/intern/mallocn.c +++ b/intern/guardedalloc/intern/mallocn.c @@ -21,7 +21,7 @@ /* If JEMALLOC is used, it reads this global variable and enables background * threads to purge dirty pages. Otherwise we release memory too slowly or not * at all if the thread that did the allocation stays inactive. */ -const char *malloc_conf = "background_thread:true,dirty_decay_ms:4000"; +const char *malloc_conf = "background_thread:true,dirty_decay_ms:4000,thp:always,metadata_thp:always"; #endif /* NOTE: Keep in sync with MEM_use_lockfree_allocator(). */