From 4142ed5f67f61adc33b61f6492fbb97690fc86dc Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Thu, 24 Oct 2019 10:20:58 -0700 Subject: [PATCH] ARROW-6977: [C++] Disable jemalloc background_thread on macOS The option isn't always available, perhaps based on the macOS version or configured SDK version. Closes #5729 from pitrou/ARROW-6977-macos-jemalloc-background-thread and squashes the following commits: 42ff1a9b0 ARROW-6977: Disable jemalloc background_thread on macOS Authored-by: Antoine Pitrou Signed-off-by: Neal Richardson --- .github/workflows/windows-msvc-cpp.yml | 2 ++ cpp/src/arrow/memory_pool.cc | 31 ++++++++++++++++---------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/.github/workflows/windows-msvc-cpp.yml b/.github/workflows/windows-msvc-cpp.yml index c77b7a737132e..824bfad403a0b 100644 --- a/.github/workflows/windows-msvc-cpp.yml +++ b/.github/workflows/windows-msvc-cpp.yml @@ -36,6 +36,7 @@ jobs: steps: - uses: actions/checkout@master - name: CMake + shell: cmd run: | mkdir build\cpp cmake ^ @@ -48,5 +49,6 @@ jobs: -S cpp ^ -B build\cpp - name: Install + shell: cmd run: | cmake --build build\cpp --config Debug --target Install diff --git a/cpp/src/arrow/memory_pool.cc b/cpp/src/arrow/memory_pool.cc index e88ac1c4c8ae2..70e9c663bd334 100644 --- a/cpp/src/arrow/memory_pool.cc +++ b/cpp/src/arrow/memory_pool.cc @@ -53,22 +53,29 @@ // aggressively (and in the background) to the OS. This can be configured // further by using the arrow::jemalloc_set_decay_ms API +#undef USE_JEMALLOC_BACKGROUND_THREAD +#ifndef __APPLE__ +// ARROW-6977: jemalloc's background_thread isn't always enabled on macOS +#define USE_JEMALLOC_BACKGROUND_THREAD +#endif + +// In debug mode, add memory poisoning on alloc / free #ifdef NDEBUG -const char* je_arrow_malloc_conf = - ("oversize_threshold:0," - "dirty_decay_ms:1000," - "muzzy_decay_ms:1000," - "background_thread:true"); +#define JEMALLOC_DEBUG_OPTIONS "" #else -// In debug mode, add memory poisoning on alloc / free -const char* je_arrow_malloc_conf = - ("oversize_threshold:0," - "junk:true," - "dirty_decay_ms:1000," - "muzzy_decay_ms:1000," - "background_thread:true"); +#define JEMALLOC_DEBUG_OPTIONS ",junk:true" #endif + +const char* je_arrow_malloc_conf = + ("oversize_threshold:0" + ",dirty_decay_ms:1000" + ",muzzy_decay_ms:1000" +#ifdef USE_JEMALLOC_BACKGROUND_THREAD + ",background_thread:true" #endif + JEMALLOC_DEBUG_OPTIONS); // NOLINT: whitespace/parens + +#endif // ARROW_JEMALLOC namespace arrow {