diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt index aed9103ec3..abad57d879 100644 --- a/be/CMakeLists.txt +++ b/be/CMakeLists.txt @@ -43,6 +43,14 @@ if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(ppc64le.*|PPC64LE.*)") set (ARCH_PPC64LE 1) endif () +if (CMAKE_SYSTEM_NAME MATCHES "Linux") + set (OS_LINUX 1) + add_definitions(-D OS_LINUX) +elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin") + set (OS_MACOSX 1) + add_definitions(-D OS_MACOSX) +endif () + if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set (COMPILER_GCC 1) elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") diff --git a/be/src/vec/common/allocator.h b/be/src/vec/common/allocator.h index 216864dbb8..0c8cfc6490 100644 --- a/be/src/vec/common/allocator.h +++ b/be/src/vec/common/allocator.h @@ -152,6 +152,13 @@ public: } /// No need for zero-fill, because mmap guarantees it. + + if constexpr (mmap_populate) { + // MAP_POPULATE seems have no effect for mremap as for mmap, + // Clear enlarged memory range explicitly to pre-fault the pages + if (new_size > old_size) + memset(reinterpret_cast(buf) + old_size, 0, new_size - old_size); + } } else if (new_size < MMAP_THRESHOLD) { /// Small allocs that requires a copy. Assume there's enough memory in system. Call CurrentMemoryTracker once. // CurrentMemoryTracker::realloc(old_size, new_size);