diff --git a/deps/Makefile b/deps/Makefile index 28cf4e01d..37f1b4117 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -37,7 +37,9 @@ distclean: -(cd hiredis && $(MAKE) clean) > /dev/null || true -(cd linenoise && $(MAKE) clean) > /dev/null || true -(cd lua && $(MAKE) clean) > /dev/null || true +ifneq ($(USE_SYSTEM_JEMALLOC),yes) -(cd jemalloc && [ -f Makefile ] && $(MAKE) distclean) > /dev/null || true +endif -(cd rocksdb && $(MAKE) clean) > /dev/null || true -(cd hdr_histogram && $(MAKE) clean) > /dev/null || true -(rm -f .make-*) diff --git a/pkg/deb/debian_dh9/patches/0010-Add-support-for-USE_SYSTEM_JEMALLOC-flag.patch b/pkg/deb/debian_dh9/patches/0010-Add-support-for-USE_SYSTEM_JEMALLOC-flag.patch deleted file mode 100644 index d7f8b2d1e..000000000 --- a/pkg/deb/debian_dh9/patches/0010-Add-support-for-USE_SYSTEM_JEMALLOC-flag.patch +++ /dev/null @@ -1,107 +0,0 @@ -From: Chris Lamb -Date: Sat, 25 Aug 2018 17:52:13 +0200 -Subject: Add support for USE_SYSTEM_JEMALLOC flag. - -https://github.com/antirez/redis/pull/5279 ---- - deps/Makefile | 2 ++ - src/Makefile | 5 +++++ - src/object.c | 5 +++++ - src/zmalloc.c | 10 ++++++++++ - src/zmalloc.h | 4 ++++ - 5 files changed, 26 insertions(+) - -diff --git a/deps/Makefile b/deps/Makefile -index eb35c1e..1342fac 100644 ---- a/deps/Makefile -+++ b/deps/Makefile -@@ -36,7 +36,9 @@ distclean: - -(cd hiredis && $(MAKE) clean) > /dev/null || true - -(cd linenoise && $(MAKE) clean) > /dev/null || true - -(cd lua && $(MAKE) clean) > /dev/null || true -+ifneq ($(USE_SYSTEM_JEMALLOC),yes) - -(cd jemalloc && [ -f Makefile ] && $(MAKE) distclean) > /dev/null || true -+endif - -(rm -f .make-*) - - .PHONY: distclean -diff --git a/src/Makefile b/src/Makefile -index 0ff6e8b..51363fe 100644 ---- a/src/Makefile -+++ b/src/Makefile -@@ -120,10 +120,15 @@ ifeq ($(MALLOC),tcmalloc_minimal) - endif - - ifeq ($(MALLOC),jemalloc) -+ifeq ($(USE_SYSTEM_JEMALLOC),yes) -+ FINAL_CFLAGS+= -DUSE_JEMALLOC -I/usr/include/jemalloc/include -+ FINAL_LIBS := -ljemalloc $(FINAL_LIBS) -+else - DEPENDENCY_TARGETS+= jemalloc - FINAL_CFLAGS+= -DUSE_JEMALLOC -I../deps/jemalloc/include - FINAL_LIBS := ../deps/jemalloc/lib/libjemalloc.a $(FINAL_LIBS) - endif -+endif - - REDIS_CC=$(QUIET_CC)$(CC) $(FINAL_CFLAGS) $(CPPFLAGS) - REDIS_LD=$(QUIET_LINK)$(CC) $(FINAL_LDFLAGS) -diff --git a/src/object.c b/src/object.c -index 6987e1e..e49c2c2 100644 ---- a/src/object.c -+++ b/src/object.c -@@ -36,6 +36,11 @@ - #define strtold(a,b) ((long double)strtod((a),(b))) - #endif - -+#if defined(USE_JEMALLOC) && (USE_SYSTEM_JEMALLOC == yes) -+#define je_mallctl mallctl -+#define je_malloc_stats_print malloc_stats_print -+#endif -+ - /* ===================== Creation and parsing of objects ==================== */ - - robj *createObject(int type, void *ptr) { -diff --git a/src/zmalloc.c b/src/zmalloc.c -index 2482f51..80e6571 100644 ---- a/src/zmalloc.c -+++ b/src/zmalloc.c -@@ -63,6 +63,15 @@ void zlibc_free(void *ptr) { - #define realloc(ptr,size) tc_realloc(ptr,size) - #define free(ptr) tc_free(ptr) - #elif defined(USE_JEMALLOC) -+#if USE_SYSTEM_JEMALLOC == yes -+#define malloc(size) malloc(size) -+#define calloc(count,size) calloc(count,size) -+#define realloc(ptr,size) realloc(ptr,size) -+#define free(ptr) free(ptr) -+#define mallocx(size,flags) mallocx(size,flags) -+#define dallocx(ptr,flags) dallocx(ptr,flags) -+#define je_mallctl mallctl -+#else - #define malloc(size) je_malloc(size) - #define calloc(count,size) je_calloc(count,size) - #define realloc(ptr,size) je_realloc(ptr,size) -@@ -70,6 +79,7 @@ void zlibc_free(void *ptr) { - #define mallocx(size,flags) je_mallocx(size,flags) - #define dallocx(ptr,flags) je_dallocx(ptr,flags) - #endif -+#endif - - #define update_zmalloc_stat_alloc(__n) do { \ - size_t _n = (__n); \ -diff --git a/src/zmalloc.h b/src/zmalloc.h -index 6fb19b0..62ccf29 100644 ---- a/src/zmalloc.h -+++ b/src/zmalloc.h -@@ -50,7 +50,11 @@ - #include - #if (JEMALLOC_VERSION_MAJOR == 2 && JEMALLOC_VERSION_MINOR >= 1) || (JEMALLOC_VERSION_MAJOR > 2) - #define HAVE_MALLOC_SIZE 1 -+#if USE_SYSTEM_JEMALLOC == yes -+#define zmalloc_size(p) malloc_usable_size(p) -+#else - #define zmalloc_size(p) je_malloc_usable_size(p) -+#endif - #else - #error "Newer version of jemalloc required" - #endif diff --git a/pkg/deb/debian_dh9/patches/series b/pkg/deb/debian_dh9/patches/series index ccb3d98d6..3e108036d 100644 --- a/pkg/deb/debian_dh9/patches/series +++ b/pkg/deb/debian_dh9/patches/series @@ -2,7 +2,6 @@ #debian-packaging/0003-dpkg-buildflags.patch #debian-packaging/0007-Set-Debian-configuration-defaults.patch #0010-Use-get_current_dir_name-over-PATHMAX-etc.patch -#0010-Add-support-for-USE_SYSTEM_JEMALLOC-flag.patch #0011-Add-support-for-a-USE_SYSTEM_LUA-flag.patch #0007-Add-support-for-a-USE_SYSTEM_HIREDIS-flag.patch #test diff --git a/src/Makefile b/src/Makefile index 9452f5959..493a1db17 100644 --- a/src/Makefile +++ b/src/Makefile @@ -317,11 +317,17 @@ ifeq ($(MALLOC),tcmalloc_minimal) endif ifeq ($(MALLOC),jemalloc) +ifeq ($(USE_SYSTEM_JEMALLOC),yes) + FINAL_CFLAGS+= -DUSE_JEMALLOC $(shell $(PKG_CONFIG) --cflags jemalloc) + FINAL_CXXFLAGS+= -DUSE_JEMALLOC $(shell $(PKG_CONFIG) --cflags jemalloc) + FINAL_LIBS := $(shell $(PKG_CONFIG) --libs jemalloc) $(FINAL_LIBS) +else DEPENDENCY_TARGETS+= jemalloc FINAL_CFLAGS+= -DUSE_JEMALLOC -I../deps/jemalloc/include FINAL_CXXFLAGS+= -DUSE_JEMALLOC -I../deps/jemalloc/include FINAL_LIBS := ../deps/jemalloc/lib/libjemalloc.a $(FINAL_LIBS) endif +endif ifeq ($(MALLOC),memkind) DEPENDENCY_TARGETS+= memkind @@ -422,6 +428,7 @@ persist-settings: distclean echo OPT=$(OPT) >> .make-settings echo USE_SYSTEM_CONCURRENTQUEUE=$(USE_SYSTEM_CONCURRENTQUEUE) >> .make-settings echo MALLOC=$(MALLOC) >> .make-settings + echo USE_SYSTEM_JEMALLOC=$(USE_SYSTEM_JEMALLOC) >> .make-settings echo BUILD_TLS=$(BUILD_TLS) >> .make-settings echo USE_SYSTEMD=$(USE_SYSTEMD) >> .make-settings echo CFLAGS=$(CFLAGS) >> .make-settings