From 9caaa4bfbdca62361e42d8ea272f087daee5aca1 Mon Sep 17 00:00:00 2001 From: Xinyi Zou Date: Fri, 26 Aug 2022 14:28:12 +0800 Subject: [PATCH] [fix](memory) fix set disable_chunk_allocator_in_vec=false performance #12092 --- be/src/common/config.h | 2 +- be/src/vec/common/allocator.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/be/src/common/config.h b/be/src/common/config.h index 54f4629b24..db103062fc 100644 --- a/be/src/common/config.h +++ b/be/src/common/config.h @@ -456,7 +456,7 @@ CONF_Int32(min_chunk_reserved_bytes, "1024"); // of gperftools tcmalloc central lock. // Jemalloc or google tcmalloc have core cache, Chunk Allocator may no longer be needed after replacing // gperftools tcmalloc. -CONF_mBool(disable_chunk_allocator_in_vec, "true"); +CONF_mBool(disable_chunk_allocator_in_vec, "false"); // The probing algorithm of partitioned hash table. // Enable quadratic probing hash table diff --git a/be/src/vec/common/allocator.h b/be/src/vec/common/allocator.h index 675c30eda4..5f2e642f26 100644 --- a/be/src/vec/common/allocator.h +++ b/be/src/vec/common/allocator.h @@ -195,7 +195,7 @@ public: if (old_size == new_size) { /// nothing to do. /// BTW, it's not possible to change alignment while doing realloc. - } else if (old_size < MMAP_THRESHOLD && new_size < MMAP_THRESHOLD && + } else if (old_size < CHUNK_THRESHOLD && new_size < CHUNK_THRESHOLD && alignment <= MALLOC_MIN_ALIGNMENT) { /// Resize malloc'd memory region with no special alignment requirement. void* new_buf = ::realloc(buf, new_size); @@ -233,6 +233,7 @@ public: memset(reinterpret_cast(buf) + old_size, 0, new_size - old_size); } } else { + // CHUNK_THRESHOLD <= old_size <= MMAP_THRESHOLD use system realloc is slow, use ChunkAllocator. // Big allocs that requires a copy. void* new_buf = alloc(new_size, alignment); memcpy(new_buf, buf, std::min(old_size, new_size));