]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Allow building rspamd with jemalloc
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 11 Apr 2016 10:23:47 +0000 (11:23 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 11 Apr 2016 10:23:47 +0000 (11:23 +0100)
CMakeLists.txt
config.h.in

index e111ec3aaa0cdfff366f6637d31144b5259f73b4..d8e39300ab1491f6f8749804325c7b25e0d92b48 100644 (file)
@@ -60,6 +60,7 @@ OPTION(ENABLE_CLANG_PLUGIN "Enable clang static analysing plugin [default: OFF]"
 OPTION(ENABLE_HYPERSCAN    "Enable hyperscan for fast regexp processing [default: OFF]" OFF)
 OPTION(ENABLE_FANN         "Enable fann for neural network plugin [default: OFF]" OFF)
 OPTION(ENABLE_PCRE2        "Enable pcre2 instead of pcre  [default: OFF]"         OFF)
+OPTION(ENABLE_JEMALLOC     "Build rspamd with jemalloc allocator  [default: OFF]" OFF)
 
 INCLUDE(FindArch.cmake)
 TARGET_ARCHITECTURE(ARCH)
@@ -653,6 +654,11 @@ ELSE()
        ProcessPackage(PCRE LIBRARY pcre INCLUDE pcre.h INCLUDE_SUFFIXES include/pcre
                ROOT ${PCRE_ROOT_DIR} MODULES pcre libpcre pcre3 libpcre3)
 ENDIF()
+IF(ENABLE_JEMALLOC MATCHES "ON")
+       ProcessPackage(JEMALLOC LIBRARY jemalloc INCLUDE jemalloc.h INCLUDE_SUFFIXES include/jemalloc
+               ROOT ${JEMALLOC_ROOT_DIR} MODULES jemalloc)
+       SET(WITH_JEMALLOC "1")
+ENDIF()
 ProcessPackage(GMIME LIBRARY gmime-2.6 gmime-2.4 gmime-2.2 gmime-2 INCLUDE gmime.h INCLUDE_SUFFIXES include/gmime
        ROOT ${GMIME_ROOT_DIR} MODULES gmime-2.6 gmime-2.4 gmime-2.0)
 ProcessPackage(LIBEVENT LIBRARY event INCLUDE event.h INCLUDE_SUFFIXES include/event
index 50a17c0a59b17e7d9996b953941685807b901aa7..2b553efe3c757b2c41b160d4caaa16f90381e55c 100644 (file)
 #cmakedefine WITH_GPERF_TOOLS    1
 #cmakedefine WITH_HIREDIS        1
 #cmakedefine WITH_HYPERSCAN      1
+#cmakedefine WITH_JEMALLOC       1
 #cmakedefine WITH_JUDY           1
 #cmakedefine WITH_LUA            1
 #cmakedefine WITH_PCRE2          1
 #include <stdlib.h>
 #endif
 
+#ifdef WITH_JEMALLOC
+#include <jemalloc.h>
+#endif
+
 /* stdio */
 #ifdef HAVE_STDIO_H
 #include <stdio.h>
@@ -330,4 +335,12 @@ typedef off_t goffset;
 extern uint64_t ottery_rand_uint64(void);
 #define UCL_RANDOM_FUNCTION ottery_rand_uint64()
 
+/* Disable slab allocator if jemalloc is already in the system */
+#if defined(WITH_JEMALLOC) || defined(__FreeBSD__) || \
+       (defined(__NetBSD__) && __NetBSD_Version__ >= 500000000)
+       #define g_slice_alloc(sz) g_malloc(sz)
+       #define g_slice_alloc0(sz) g_malloc0(sz)
+       #define g_slice_free1(sz, p) g_free(p)
+#endif
+
 #endif