Properly integrate memkind
Former-commit-id: 82372cbce84a009ef162a611bb91c7ed67acc9e9
This commit is contained in:
parent
833006226d
commit
bb9f3eeb13
5
deps/Makefile
vendored
5
deps/Makefile
vendored
@ -53,6 +53,11 @@ linenoise: .make-prerequisites
|
|||||||
|
|
||||||
.PHONY: linenoise
|
.PHONY: linenoise
|
||||||
|
|
||||||
|
.PHONY: memkind
|
||||||
|
memkind:
|
||||||
|
cd memkind && $(MAKE)
|
||||||
|
|
||||||
|
|
||||||
ifeq ($(uname_S),SunOS)
|
ifeq ($(uname_S),SunOS)
|
||||||
# Make isinf() available
|
# Make isinf() available
|
||||||
LUA_CFLAGS= -D__C99FEATURES__=1
|
LUA_CFLAGS= -D__C99FEATURES__=1
|
||||||
|
12
deps/memkind/Makefile
vendored
Normal file
12
deps/memkind/Makefile
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
export JE_PREFIX=jemk_
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
all:
|
||||||
|
cd src; ./build_jemalloc.sh
|
||||||
|
cd src; ./build.sh
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
cd src; make clean
|
||||||
|
|
||||||
|
|
10
src/Makefile
10
src/Makefile
@ -38,7 +38,7 @@ MALLOC=libc
|
|||||||
ifneq ($(uname_M),armv6l)
|
ifneq ($(uname_M),armv6l)
|
||||||
ifneq ($(uname_M),armv7l)
|
ifneq ($(uname_M),armv7l)
|
||||||
ifeq ($(uname_S),Linux)
|
ifeq ($(uname_S),Linux)
|
||||||
MALLOC=jemalloc
|
MALLOC=memkind
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -119,7 +119,7 @@ ifeq ($(uname_S),DragonFly)
|
|||||||
else
|
else
|
||||||
# All the other OSes (notably Linux)
|
# All the other OSes (notably Linux)
|
||||||
FINAL_LDFLAGS+= -rdynamic
|
FINAL_LDFLAGS+= -rdynamic
|
||||||
FINAL_LIBS+=-ldl -pthread -lrt -lmemkind
|
FINAL_LIBS+=-ldl -pthread -lrt
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -145,6 +145,12 @@ ifeq ($(MALLOC),jemalloc)
|
|||||||
FINAL_LIBS := ../deps/jemalloc/lib/libjemalloc.a $(FINAL_LIBS)
|
FINAL_LIBS := ../deps/jemalloc/lib/libjemalloc.a $(FINAL_LIBS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(MALLOC),memkind)
|
||||||
|
DEPENDENCY_TARGETS+= memkind
|
||||||
|
FINAL_CFLAGS+= -DUSE_MEMKIND -I../deps/memkind/src/include
|
||||||
|
FINAL_LIBS := ../deps/memkind/src/.libs/libmemkind.a -lnuma $(FINAL_LIBS)
|
||||||
|
endif
|
||||||
|
|
||||||
REDIS_CC=$(QUIET_CC)$(CC) $(FINAL_CFLAGS)
|
REDIS_CC=$(QUIET_CC)$(CC) $(FINAL_CFLAGS)
|
||||||
REDIS_LD=$(QUIET_LINK)$(CC) $(FINAL_LDFLAGS)
|
REDIS_LD=$(QUIET_LINK)$(CC) $(FINAL_LDFLAGS)
|
||||||
REDIS_INSTALL=$(QUIET_INSTALL)$(INSTALL)
|
REDIS_INSTALL=$(QUIET_INSTALL)$(INSTALL)
|
||||||
|
@ -72,8 +72,8 @@ void* activeDefragAlloc(void *ptr) {
|
|||||||
/* move this allocation to a new allocation.
|
/* move this allocation to a new allocation.
|
||||||
* make sure not to use the thread cache. so that we don't get back the same
|
* make sure not to use the thread cache. so that we don't get back the same
|
||||||
* pointers we try to free */
|
* pointers we try to free */
|
||||||
size = zmalloc_size(ptr, MALLOC_LOCAL);
|
size = zmalloc_size(ptr);
|
||||||
newptr = zmalloc_no_tcache(size, MALLOC_LOCAL);
|
newptr = zmalloc_no_tcache(size);
|
||||||
memcpy(newptr, ptr, size);
|
memcpy(newptr, ptr, size);
|
||||||
zfree_no_tcache(ptr);
|
zfree_no_tcache(ptr);
|
||||||
return newptr;
|
return newptr;
|
||||||
|
@ -57,7 +57,12 @@ void zlibc_free(void *ptr) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Explicitly override malloc/free etc when using tcmalloc. */
|
/* Explicitly override malloc/free etc when using tcmalloc. */
|
||||||
#if defined(USE_TCMALLOC)
|
#if defined(USE_MEMKIND)
|
||||||
|
#define malloc(size, type) salloc(size, type)
|
||||||
|
#define calloc(count, size, type) scalloc(count, size, type)
|
||||||
|
#define realloc(ptr, size) srealloc(ptr, size)
|
||||||
|
#define free(ptr) sfree(ptr)
|
||||||
|
#elif defined(USE_TCMALLOC)
|
||||||
#define malloc(size) tc_malloc(size)
|
#define malloc(size) tc_malloc(size)
|
||||||
#define calloc(count,size) tc_calloc(count,size)
|
#define calloc(count,size) tc_calloc(count,size)
|
||||||
#define realloc(ptr,size) tc_realloc(ptr,size)
|
#define realloc(ptr,size) tc_realloc(ptr,size)
|
||||||
@ -70,16 +75,6 @@ void zlibc_free(void *ptr) {
|
|||||||
#define mallocx(size,flags) je_mallocx(size,flags)
|
#define mallocx(size,flags) je_mallocx(size,flags)
|
||||||
#define dallocx(ptr,flags) je_dallocx(ptr,flags)
|
#define dallocx(ptr,flags) je_dallocx(ptr,flags)
|
||||||
#endif
|
#endif
|
||||||
#include "storage.h"
|
|
||||||
#undef malloc
|
|
||||||
#undef calloc
|
|
||||||
#undef realloc
|
|
||||||
#undef free
|
|
||||||
#define malloc(size, type) salloc(size, type)
|
|
||||||
#define calloc(count, size, type) scalloc(count, size, type)
|
|
||||||
#define realloc(ptr, size) srealloc(ptr, size)
|
|
||||||
#define free(ptr) sfree(ptr)
|
|
||||||
//#define zmalloc_size(ptr) (sizeof(ptr))
|
|
||||||
|
|
||||||
#define update_zmalloc_stat_alloc(__n) do { \
|
#define update_zmalloc_stat_alloc(__n) do { \
|
||||||
size_t _n = (__n); \
|
size_t _n = (__n); \
|
||||||
@ -106,7 +101,12 @@ static void zmalloc_default_oom(size_t size) {
|
|||||||
static void (*zmalloc_oom_handler)(size_t) = zmalloc_default_oom;
|
static void (*zmalloc_oom_handler)(size_t) = zmalloc_default_oom;
|
||||||
|
|
||||||
void *zmalloc(size_t size, enum MALLOC_CLASS class) {
|
void *zmalloc(size_t size, enum MALLOC_CLASS class) {
|
||||||
|
#ifdef USE_MEMKIND
|
||||||
void *ptr = malloc(size+PREFIX_SIZE, class);
|
void *ptr = malloc(size+PREFIX_SIZE, class);
|
||||||
|
#else
|
||||||
|
(void)class;
|
||||||
|
void *ptr = malloc(size+PREFIX_SIZE);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!ptr) zmalloc_oom_handler(size);
|
if (!ptr) zmalloc_oom_handler(size);
|
||||||
#ifdef HAVE_MALLOC_SIZE
|
#ifdef HAVE_MALLOC_SIZE
|
||||||
@ -138,7 +138,12 @@ void zfree_no_tcache(void *ptr) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void *zcalloc(size_t size, enum MALLOC_CLASS class) {
|
void *zcalloc(size_t size, enum MALLOC_CLASS class) {
|
||||||
|
#ifdef USE_MEMKIND
|
||||||
void *ptr = calloc(1, size+PREFIX_SIZE, class);
|
void *ptr = calloc(1, size+PREFIX_SIZE, class);
|
||||||
|
#else
|
||||||
|
(void)class;
|
||||||
|
void *ptr = calloc(1, size+PREFIX_SIZE);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!ptr) zmalloc_oom_handler(size);
|
if (!ptr) zmalloc_oom_handler(size);
|
||||||
#ifdef HAVE_MALLOC_SIZE
|
#ifdef HAVE_MALLOC_SIZE
|
||||||
|
@ -35,9 +35,9 @@
|
|||||||
#define __xstr(s) __str(s)
|
#define __xstr(s) __str(s)
|
||||||
#define __str(s) #s
|
#define __str(s) #s
|
||||||
|
|
||||||
#if 1
|
#include "storage.h"
|
||||||
#define ZMALLOC_LIB ("custom")
|
#if defined(USE_MEMKIND)
|
||||||
#include "storage.h"
|
#define ZMALLOC_LIB ("memkind")
|
||||||
#undef USE_JEMALLOC
|
#undef USE_JEMALLOC
|
||||||
#define USE_MALLOC_CLASS 1
|
#define USE_MALLOC_CLASS 1
|
||||||
#elif defined(USE_TCMALLOC)
|
#elif defined(USE_TCMALLOC)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user