[Enhancement][Vectorized] Improve hash table build efficiency (#9250)

1. MAP_POPULATE is missing for mmap in Allocator, because macro OS_LINUX is not defined in allocator.h;
2. MAP_POPULATE has no effect for mremap as for mmap, zero-fill enlarged memory range explicitly to pre-fault the pages
This commit is contained in:
jacktengg
2022-04-29 14:26:33 +08:00
committed by GitHub
parent ce7905e983
commit 201cd207f9
2 changed files with 15 additions and 0 deletions

View File

@ -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")

View File

@ -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<char*>(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);