[part-2] Split plan memory to tenants

This commit is contained in:
obdev
2023-06-02 04:11:57 +00:00
committed by ob-robot
parent a7e3b054fd
commit 0e941a7b37
5 changed files with 25 additions and 13 deletions

View File

@ -430,7 +430,6 @@ void* ObTenantCtxAllocator::common_alloc(const int64_t size, const ObMemAttr &at
attr.tenant_id_, attr.ctx_id_,
get_global_ctx_info().get_ctx_name(attr.ctx_id_),
ta.get_hold(), ta.get_limit(), ta.get_tenant_hold(), ta.get_tenant_limit());
ObMallocAllocator::get_instance()->print_tenant_memory_usage(attr.tenant_id_);
// 49 is the user defined signal to dump memory
raise(49);
}

View File

@ -258,7 +258,13 @@ public:
template<typename ... Args>
inline int prepare_allocate(int64_t capacity, Args && ... args)
{
return inner_prepare_allocate(capacity, args...);
return inner_prepare_allocate(capacity, false, args...);
}
template<typename ... Args>
inline int prepare_allocate_and_keep_count(int64_t capacity, Args && ... args)
{
return inner_prepare_allocate(capacity, true, args...);
}
inline ObFixedArrayImpl(const ObFixedArrayImpl<T, AllocatorT> &other)
@ -281,7 +287,9 @@ public:
NEED_SERIALIZE_AND_DESERIALIZE;
private:
template<typename ... Args>
inline int inner_prepare_allocate(int64_t capacity, Args && ... args)
inline int inner_prepare_allocate(int64_t capacity,
const bool keep_count,
Args && ... args)
{
int ret = OB_SUCCESS;
if (capacity < 0 || capacity > UINT32_MAX) {
@ -294,7 +302,9 @@ private:
for (int64_t i = init_cnt_; i < capacity; i++) {
new(&data_[i]) T(args...);
}
if (!keep_count) {
count_ = static_cast<uint32_t>(capacity > count_ ? capacity : count_);
}
init_cnt_ = static_cast<uint32_t>(capacity >init_cnt_ ? capacity : init_cnt_);
}
return ret;

View File

@ -777,9 +777,11 @@ int ObPhysicalPlan::set_table_locations(const ObTablePartitionInfoArray &infos,
int ret = OB_SUCCESS;
table_locations_.reset();
das_table_locations_.reset();
if (OB_FAIL(table_locations_.init(infos.count()))) {
if (OB_FAIL(table_locations_.prepare_allocate_and_keep_count(infos.count(),
allocator_))) {
LOG_WARN("fail to init table location count", K(ret));
} else if (OB_FAIL(das_table_locations_.init(infos.count()))) {
} else if (OB_FAIL(das_table_locations_.prepare_allocate_and_keep_count(infos.count(),
allocator_))) {
LOG_WARN("fail to init das table location count", K(ret));
}
for (int64_t i = 0; OB_SUCC(ret) && i < infos.count(); ++i) {

View File

@ -48,7 +48,6 @@ namespace sql
{
ObPlanSet::~ObPlanSet()
{
// Make sure destory planset before destory pre calculable expression.
if (OB_ISNULL(pre_cal_expr_handler_)) {
// have no pre calculable expression, do nothing
@ -1281,6 +1280,9 @@ int ObSqlPlanSet::init_new_set(const ObPlanCacheCtx &pc_ctx,
LOG_WARN("pc_allocator has not been initialized.", K(ret));
} else if (OB_FAIL(ObPlanSet::init_new_set(pc_ctx, plan, outline_param_idx, pc_malloc_))) {
LOG_WARN("init new set failed", K(ret));
} else if (OB_FAIL(table_locations_.prepare_allocate_and_keep_count(sql_ctx.partition_infos_.count(),
*plan_cache_value_->get_pcv_set()->get_allocator()))) {
LOG_WARN("fail to init table location count", K(ret));
} else if (OB_FAIL(dist_plans_.init(this))) {
SQL_PC_LOG(WARN, "failed to init dist plans", K(ret));
} else {

View File

@ -250,7 +250,7 @@ public:
ObSqlPlanSet()
: ObPlanSet(PST_SQL_CRSR),
is_all_non_partition_(true),
table_locations_(), // use default behavior for memory release
table_locations_(alloc_),
array_binding_plan_(),
local_plan_(NULL),
remote_plan_(NULL),
@ -262,7 +262,6 @@ public:
is_contain_virtual_table_(false),
enable_inner_part_parallel_exec_(false)
{
table_locations_.set_attr(ObMemAttr(OB_SERVER_TENANT_ID, "TableLocations"));
}
virtual ~ObSqlPlanSet() {}
@ -357,7 +356,7 @@ private:
bool is_local_plan_opt_allowed(int last_retry_err);
private:
bool is_all_non_partition_; //判断该plan对应的表是否均为非分区表
common::ObSEArray<ObTableLocation, 1> table_locations_;
TableLocationFixedArray table_locations_;
//used for array binding, only local plan
ObPhysicalPlan *array_binding_plan_;
ObPhysicalPlan *local_plan_;