From 4bc79bca35a046ed2e657e6edf3f332fe60873e9 Mon Sep 17 00:00:00 2001 From: chertus Date: Tue, 16 Jul 2019 17:18:01 +0300 Subject: [PATCH] fix unbandled build & add comment --- dbms/src/Common/MemoryTracker.cpp | 1 + dbms/src/Common/config.h.in | 1 - libs/libcommon/include/common/memory.h | 12 ++++++++++-- libs/libcommon/src/jemalloc_cpp.cpp | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/dbms/src/Common/MemoryTracker.cpp b/dbms/src/Common/MemoryTracker.cpp index 380dee75748..f59e4789b43 100644 --- a/dbms/src/Common/MemoryTracker.cpp +++ b/dbms/src/Common/MemoryTracker.cpp @@ -17,6 +17,7 @@ namespace DB static constexpr size_t log_peak_memory_usage_every = 1ULL << 30; +/// Each thread could new/delete memory in range of (-untracked_memory_limit, untracked_memory_limit) without access to common counters. static constexpr Int64 untracked_memory_limit = 4 * 1024 * 1024; diff --git a/dbms/src/Common/config.h.in b/dbms/src/Common/config.h.in index 556eeebec58..9b38dd9fc04 100644 --- a/dbms/src/Common/config.h.in +++ b/dbms/src/Common/config.h.in @@ -9,6 +9,5 @@ #cmakedefine01 USE_CPUINFO #cmakedefine01 USE_BROTLI #cmakedefine01 USE_MIMALLOC -#cmakedefine01 USE_JEMALLOC #cmakedefine01 CLICKHOUSE_SPLIT_BINARY diff --git a/libs/libcommon/include/common/memory.h b/libs/libcommon/include/common/memory.h index bcb49b957b2..93a8c600754 100644 --- a/libs/libcommon/include/common/memory.h +++ b/libs/libcommon/include/common/memory.h @@ -7,6 +7,16 @@ #include #endif +#if USE_JEMALLOC +#include + +#if JEMALLOC_VERSION_MAJOR < 4 + #undef USE_JEMALLOC + #define USE_JEMALLOC 0 + #include +#endif +#endif + #if defined(_MSC_VER) #define ALWAYS_INLINE __forceinline #define NO_INLINE static __declspec(noinline) @@ -17,8 +27,6 @@ #if USE_JEMALLOC -#include - namespace JeMalloc { diff --git a/libs/libcommon/src/jemalloc_cpp.cpp b/libs/libcommon/src/jemalloc_cpp.cpp index fbf074a0fb5..fdf941652c7 100644 --- a/libs/libcommon/src/jemalloc_cpp.cpp +++ b/libs/libcommon/src/jemalloc_cpp.cpp @@ -5,7 +5,7 @@ namespace JeMalloc { -void * handleOOM(std::size_t size, bool nothrow) +NO_INLINE void * handleOOM(std::size_t size, bool nothrow) { void * ptr = nullptr;