Skip to content

Commit

Permalink
Latest versions of Jemalloc library do not require je_init()/je_unint()
Browse files Browse the repository at this point in the history
  calls. #ifdef in the source code and make this a default build option.
  • Loading branch information
yuslepukhin committed Mar 17, 2016
1 parent 90aff0c commit 2ca0994
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions port/win/port_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ int GetMaxOpenFiles() { return -1; }

#include "jemalloc/jemalloc.h"

#ifndef JEMALLOC_NON_INIT

namespace rocksdb {

namespace port {
Expand Down Expand Up @@ -278,6 +280,8 @@ JEMALLOC_SECTION(".CRT$XCT") JEMALLOC_ATTR(used) static const void(

} // extern "C"

#endif // JEMALLOC_NON_INIT

// Global operators to be replaced by a linker

void* operator new(size_t size) {
Expand Down
15 changes: 14 additions & 1 deletion thirdparty.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set(USE_SNAPPY_DEFAULT 0) # SNAPPY is disabled by default, enable with -D
set(USE_LZ4_DEFAULT 0) # LZ4 is disabled by default, enable with -DLZ4=1 cmake command line agrument
set(USE_ZLIB_DEFAULT 0) # ZLIB is disabled by default, enable with -DZLIB=1 cmake command line agrument
set(USE_JEMALLOC_DEFAULT 0) # JEMALLOC is disabled by default, enable with -DJEMALLOC=1 cmake command line agrument
set(USE_JENONINIT_DEFAULT 1) # Default is enabled do not call je_init/je_uninit as the newer versions do not have it disable with -DJENONINIT=0

#
# This example assumes all the libraries locate in directories under THIRDPARTY_HOME environment variable
Expand Down Expand Up @@ -208,7 +209,7 @@ endif ()

if (${USE_JEMALLOC} EQUAL 1)
message(STATUS "JEMALLOC library is enabled")
set(JEMALLOC_CXX_FLAGS -DJEMALLOC)
set(JEMALLOC_CXX_FLAGS "-DJEMALLOC -DJEMALLOC_EXPORT= ")

if(DEFINED ENV{JEMALLOC_INCLUDE})
set(JEMALLOC_INCLUDE $ENV{JEMALLOC_INCLUDE})
Expand All @@ -228,6 +229,18 @@ if (${USE_JEMALLOC} EQUAL 1)
include_directories(${JEMALLOC_INCLUDE})
set (THIRDPARTY_LIBS ${THIRDPARTY_LIBS} ${JEMALLOC_LIBS})
set (ARTIFACT_SUFFIX "_je")

set(USE_JENONINIT USE_JENONINIT_DEFAULT)

if(JENONINIT)
set(USE_JENONINIT ${JENONINIT})
endif()

if(${USE_JENONINIT} EQUAL 1)
add_definitions(-DJEMALLOC_NON_INIT)
message(STATUS "JEMALLOC NONINIT version")
endif()

else ()
set (ARTIFACT_SUFFIX "")
message(STATUS "JEMALLOC library is disabled")
Expand Down

0 comments on commit 2ca0994

Please sign in to comment.