From fabd82bd5eae54c0428c0e011be481e3c5c2e608 Mon Sep 17 00:00:00 2001 From: tushicheng <18829573815@163.com> Date: Mon, 2 Dec 2024 11:45:27 +0000 Subject: [PATCH] reopen memory limit of tenant_500 for core-test --- .../lib/objectpool/ob_concurrency_objpool.h | 66 +++++++++++++++++++ src/share/io/ob_io_manager.cpp | 12 ++-- src/share/io/ob_io_manager.h | 2 +- src/storage/tx/ob_trans_define_v4.h | 6 +- tools/deploy/obd/core-test.yaml.template | 2 +- 5 files changed, 79 insertions(+), 9 deletions(-) diff --git a/deps/oblib/src/lib/objectpool/ob_concurrency_objpool.h b/deps/oblib/src/lib/objectpool/ob_concurrency_objpool.h index 018fb662e..5c26bf3e3 100644 --- a/deps/oblib/src/lib/objectpool/ob_concurrency_objpool.h +++ b/deps/oblib/src/lib/objectpool/ob_concurrency_objpool.h @@ -16,6 +16,7 @@ #include #include #include "lib/allocator/ob_slice_alloc.h" +#include "lib/allocator/ob_vslice_alloc.h" namespace oceanbase { @@ -99,6 +100,47 @@ private: ObSliceAlloc allocator_; }; +template +class ObFixedClassAllocatorV2 +{ +public: + using object_type = T; +public: + ObFixedClassAllocatorV2(const ObMemAttr &attr, int64_t nway) + : allocator_(attr, OB_MALLOC_BIG_BLOCK_SIZE) + { + allocator_.set_nway(static_cast(nway)); + } + virtual ~ObFixedClassAllocatorV2() {} + + static ObFixedClassAllocatorV2 *get(const char* label = "ConcurObjPool") + { + static ObFixedClassAllocatorV2 instance(SET_USE_500(ObMemAttr(common::OB_SERVER_TENANT_ID, label)), + common::get_cpu_count()); + return &instance; + } + + void *alloc() + { + return allocator_.alloc(sizeof(T) + sizeof(ObClassMeta)); + } + + void free(void *ptr) + { + if (OB_LIKELY(NULL != ptr)) { + allocator_.free(ptr); + ptr = NULL; + } + } + void set_nway(int nway) + { + allocator_.set_nway(static_cast(nway)); + } + +private: + ObVSliceAlloc allocator_; +}; + template inline void type_checker(instance_type*, object_type*) { @@ -152,6 +194,30 @@ inline void free_helper(T *ptr) #define op_reclaim_alloc(type) op_alloc(type) #define op_reclaim_free(ptr) op_free(ptr) +template +inline void free_helper_v2(T *ptr) +{ + common::ObClassMeta *meta = reinterpret_cast((char*)ptr - sizeof(common::ObClassMeta)); + abort_unless(meta->check_magic_code()); + ptr->~T(); + ((ObFixedClassAllocatorV2*)meta->instance())->free(meta); +} + +#define op_alloc_v2(type) \ + ({ \ + OLD_STATIC_ASSERT((std::is_default_constructible::value), "type is not default constructible"); \ + common::ObFixedClassAllocatorV2 *instance = \ + common::ObFixedClassAllocatorV2::get(#type); \ + op_instance_alloc_args(instance, type); \ + }) + +#define op_free_v2(ptr) \ + ({ \ + if (OB_LIKELY(NULL != ptr)) { \ + free_helper_v2(ptr); \ + } \ + }) + } // end of namespace common } // end of namespace oceanbase diff --git a/src/share/io/ob_io_manager.cpp b/src/share/io/ob_io_manager.cpp index e4f4da80c..263dfa77c 100644 --- a/src/share/io/ob_io_manager.cpp +++ b/src/share/io/ob_io_manager.cpp @@ -1560,13 +1560,17 @@ bool ObTenantIOManager::is_working() const return ATOMIC_LOAD(&is_working_); } -int ObTenantIOManager::calc_io_memory(const int64_t memory) +int ObTenantIOManager::calc_io_memory(const uint64_t tenant_id, const int64_t memory) { int ret = OB_SUCCESS; int64_t memory_benchmark = memory / (1L * 1024L * 1024L * 1024L); //base ob 1G //1w req占用1.52M //1w result占用2.44M - if (memory_benchmark <= 1) { + if (lib::is_mini_mode() && OB_SERVER_TENANT_ID == tenant_id) { + request_count_ = 5000; + result_count_ = 5000; + io_memory_limit_ = 256L * 1024L * 1024L; + } else if (memory_benchmark <= 1) { //1G租户上限共256MB,预分配5w个request(7.6MB)和result(12.2MB) request_count_ = 50000; result_count_ = 50000; @@ -1597,7 +1601,7 @@ int ObTenantIOManager::init_memory_pool(const uint64_t tenant_id, const int64_t if (OB_UNLIKELY(tenant_id <= 0 || memory <= 0)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid io argument", K(ret), K(tenant_id), K(memory)); - } else if (OB_FAIL(calc_io_memory(memory))) { + } else if (OB_FAIL(calc_io_memory(tenant_id, memory))) { LOG_WARN("calc tenant io memory failed", K(ret), K(memory), K(io_memory_limit_), K(request_count_), K(request_count_)); } else if (OB_FAIL(io_allocator_.init(tenant_id, io_memory_limit_))) { LOG_WARN("init io allocator failed", K(ret), K(tenant_id), K(io_memory_limit_)); @@ -1617,7 +1621,7 @@ int ObTenantIOManager::update_memory_pool(const int64_t memory) if (OB_UNLIKELY(memory <= 0)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid io argument", K(ret), K(memory)); - } else if (OB_FAIL(calc_io_memory(memory))) { + } else if (OB_FAIL(calc_io_memory(tenant_id_, memory))) { LOG_WARN("calc tenant io memory failed", K(ret), K(memory), K(io_memory_limit_), K(request_count_), K(request_count_)); } else if (OB_FAIL(io_allocator_.update_memory_limit(io_memory_limit_))) { LOG_WARN("update io memory limit failed", K(ret), K(io_memory_limit_)); diff --git a/src/share/io/ob_io_manager.h b/src/share/io/ob_io_manager.h index 0aa40c788..22852fab1 100644 --- a/src/share/io/ob_io_manager.h +++ b/src/share/io/ob_io_manager.h @@ -442,7 +442,7 @@ public: int init_group_index_map(const int64_t tenant_id, const ObTenantIOConfig &io_config); int get_group_index(const ObIOGroupKey &key, uint64_t &index); int get_group_config(const ObIOGroupKey &key, ObTenantIOConfig::GroupConfig &index) const; - int calc_io_memory(const int64_t memory); + int calc_io_memory(const uint64_t tenant_id, const int64_t memory); int init_memory_pool(const uint64_t tenant_id, const int64_t memory); int update_memory_pool(const int64_t memory); int modify_group_io_config(const uint64_t index, diff --git a/src/storage/tx/ob_trans_define_v4.h b/src/storage/tx/ob_trans_define_v4.h index aae40530a..fddb7d2cb 100644 --- a/src/storage/tx/ob_trans_define_v4.h +++ b/src/storage/tx/ob_trans_define_v4.h @@ -977,7 +977,7 @@ public: ObTxDesc* alloc_value() { ATOMIC_INC(&alloc_cnt_); - ObTxDesc *it = op_alloc(ObTxDesc); + ObTxDesc *it = op_alloc_v2(ObTxDesc); #ifdef ENABLE_DEBUG_LOG ObSpinLockGuard guard(lk_); list_.insert(it->alloc_link_); @@ -992,12 +992,12 @@ public: ObSpinLockGuard guard(lk_); v->alloc_link_.remove(); #endif - op_free(v); + op_free_v2(v); } } static void force_free(ObTxDesc *v) { - op_free(v); + op_free_v2(v); } int64_t get_alloc_cnt() const { return ATOMIC_LOAD(&alloc_cnt_); } #ifdef ENABLE_DEBUG_LOG diff --git a/tools/deploy/obd/core-test.yaml.template b/tools/deploy/obd/core-test.yaml.template index 77f2cfd3c..748279b09 100644 --- a/tools/deploy/obd/core-test.yaml.template +++ b/tools/deploy/obd/core-test.yaml.template @@ -7,5 +7,5 @@ oceanbase-ce: system_memory: '1G' datafile_size: '20G' cpu_count: '24' - _system_tenant_limit_mode: '0' + _system_tenant_limit_mode: '2' {{%% PROXY_CONF %%}}