reopen memory limit of tenant_500 for core-test

This commit is contained in:
tushicheng 2024-12-02 11:45:27 +00:00 committed by ob-robot
parent 6e1de2428d
commit fabd82bd5e
5 changed files with 79 additions and 9 deletions

View File

@ -16,6 +16,7 @@
#include <typeinfo>
#include <type_traits>
#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 T>
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<int32_t>(nway));
}
virtual ~ObFixedClassAllocatorV2() {}
static ObFixedClassAllocatorV2<T> *get(const char* label = "ConcurObjPool")
{
static ObFixedClassAllocatorV2<T> 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<int32_t>(nway));
}
private:
ObVSliceAlloc allocator_;
};
template<typename instance_type, typename object_type>
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<typename T>
inline void free_helper_v2(T *ptr)
{
common::ObClassMeta *meta = reinterpret_cast<common::ObClassMeta*>((char*)ptr - sizeof(common::ObClassMeta));
abort_unless(meta->check_magic_code());
ptr->~T();
((ObFixedClassAllocatorV2<T>*)meta->instance())->free(meta);
}
#define op_alloc_v2(type) \
({ \
OLD_STATIC_ASSERT((std::is_default_constructible<type>::value), "type is not default constructible"); \
common::ObFixedClassAllocatorV2<type> *instance = \
common::ObFixedClassAllocatorV2<type>::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

View File

@ -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_));

View File

@ -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,

View File

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

View File

@ -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 %%}}