]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add recommended jemalloc configuration for our load
authorOndřej Surý <ondrej@sury.org>
Tue, 11 May 2021 10:33:31 +0000 (12:33 +0200)
committerOndřej Surý <ondrej@sury.org>
Fri, 9 Jul 2021 13:58:02 +0000 (15:58 +0200)
There's global variable called `malloc_conf` that can be used to
configure jemalloc behaviour at the program startup.  We use following
configuration:

  * xmalloc:true - abort-on-out-of-memory enabled.

  * background_thread:true - Enable internal background worker threads
    to handle purging asynchronously.

  * metadata_thp:auto - allow jemalloc to use transparent huge page
    (THP) for internal metadata initially, but may begin to do so when
    metadata usage reaches certain level.

  * dirty_decay_ms:30000 - Approximate time in milliseconds from the
    creation of a set of unused dirty pages until an equivalent set of
    unused dirty pages is purged and/or reused.

  * muzzy_decay_ms:30000 - Approximate time in milliseconds from the
    creation of a set of unused muzzy pages until an equivalent set of
    unused muzzy pages is purged and/or reused.

More information about the specific meaning can be found in the jemalloc
manpage or online at http://jemalloc.net/jemalloc.3.html

lib/isc/mem.c

index 6adfd9d671625665b6e5b3a7b0e7889596cd779f..33738b4af4c67a445a62a18bf99a85a5bf2b498e 100644 (file)
@@ -42,6 +42,8 @@
 #include <json_object.h>
 #endif /* HAVE_JSON_C */
 
+#include <jemalloc/jemalloc.h>
+
 #include "mem_p.h"
 
 #define MCTXLOCK(m)   LOCK(&m->lock)
@@ -442,6 +444,9 @@ default_memfree(void *ptr) {
 
 static void
 mem_initialize(void) {
+       malloc_conf = "xmalloc:true,background_thread:true,metadata_thp:auto,"
+                     "dirty_decay_ms:30000,muzzy_decay_ms:30000";
+
        isc_mutex_init(&contextslock);
        ISC_LIST_INIT(contexts);
        totallost = 0;