reduce memory of mod WokerMap

This commit is contained in:
sdc
2023-08-28 06:10:49 +00:00
committed by ob-robot
parent a54dafc522
commit aad707d31c
5 changed files with 17 additions and 15 deletions

View File

@ -1115,8 +1115,7 @@ int ObPhysicalPlan::set_expected_worker_map(const common::hash::ObHashMap<ObAddr
}
return ret;
}
const common::hash::ObHashMap<ObAddr, int64_t>& ObPhysicalPlan:: get_expected_worker_map() const
const ObPlanStat::AddrMap& ObPhysicalPlan:: get_expected_worker_map() const
{
return stat_.expected_worker_map_;
}
@ -1130,12 +1129,7 @@ int ObPhysicalPlan::set_minimal_worker_map(const common::hash::ObHashMap<ObAddr,
return ret;
}
const common::hash::ObHashMap<ObAddr, int64_t>& ObPhysicalPlan::get_minimal_worker_map() const
{
return stat_.minimal_worker_map_;
}
int ObPhysicalPlan::assign_worker_map(common::hash::ObHashMap<ObAddr, int64_t> &worker_map, const common::hash::ObHashMap<ObAddr, int64_t> &c)
int ObPhysicalPlan::assign_worker_map(ObPlanStat::AddrMap &worker_map, const common::hash::ObHashMap<ObAddr, int64_t> &c)
{
int ret = OB_SUCCESS;
ObMemAttr attr(MTL_ID(), "WorkerMap");

View File

@ -180,10 +180,10 @@ public:
void set_minimal_worker_count(int64_t c) { stat_.minimal_worker_count_ = c; }
int64_t get_minimal_worker_count() const { return stat_.minimal_worker_count_; }
int set_expected_worker_map(const common::hash::ObHashMap<ObAddr, int64_t> &c);
const common::hash::ObHashMap<ObAddr, int64_t>& get_expected_worker_map() const;
const ObPlanStat::AddrMap& get_expected_worker_map() const;
int set_minimal_worker_map(const common::hash::ObHashMap<ObAddr, int64_t> &c);
const common::hash::ObHashMap<ObAddr, int64_t>& get_minimal_worker_map() const;
int assign_worker_map(common::hash::ObHashMap<ObAddr, int64_t> &worker_map,
const common::hash::ObHashMap<ObAddr, int64_t>& get_minimal_worker_map() const;
int assign_worker_map(ObPlanStat::AddrMap &worker_map,
const common::hash::ObHashMap<ObAddr, int64_t> &c);
const char* get_sql_id() const { return stat_.sql_id_.ptr(); }
const ObString& get_sql_id_string() const { return stat_.sql_id_; }

View File

@ -115,7 +115,7 @@ int ObPxAdmission::enter_query_admission(ObSQLSessionInfo &session,
&& 1 != plan.get_px_dop()
&& plan.get_expected_worker_count() > 0) {
// use for appointment
const ObHashMap<ObAddr, int64_t> &req_px_worker_map = plan.get_expected_worker_map();
const auto &req_px_worker_map = plan.get_expected_worker_map();
ObHashMap<ObAddr, int64_t> &acl_px_worker_map = exec_ctx.get_admission_addr_map();
if (acl_px_worker_map.created()) {
acl_px_worker_map.clear();
@ -123,7 +123,7 @@ int ObPxAdmission::enter_query_admission(ObSQLSessionInfo &session,
LOG_WARN("create hash map failed", K(ret));
}
if (OB_SUCC(ret)) {
for (ObHashMap<ObAddr, int64_t>::const_iterator it = req_px_worker_map.begin();
for (auto it = req_px_worker_map.begin();
OB_SUCC(ret) && it != req_px_worker_map.end(); ++it) {
if (OB_FAIL(acl_px_worker_map.set_refactored(it->first, it->second))){
LOG_WARN("set refactored failed", K(ret), K(it->first), K(it->second));

View File

@ -43,6 +43,7 @@ public:
virtual int on_root_data_channel_setup() = 0;
};
struct ObExprExtraSerializeInfo
{
OB_UNIS_VERSION(1);

View File

@ -492,8 +492,15 @@ struct ObTableRowCount
};
struct ObPlanStat
{
static const int64_t DEFAULT_ADDR_NODE_NUM = 16;
typedef common::hash::ObHashMap<ObAddr, int64_t,
common::hash::LatchReadWriteDefendMode, common::hash::hash_func<ObAddr>,
common::hash::equal_to<ObAddr>,
common::hash::SimpleAllocer<typename common::hash::HashMapTypes<ObAddr, int64_t>::AllocType,
DEFAULT_ADDR_NODE_NUM>> AddrMap;
static const int32_t STMT_MAX_LEN = 4096;
static const int32_t MAX_SCAN_STAT_SIZE = 100;
static const int64_t CACHE_POLICY_UPDATE_INTERVAL = 60 * 1000 * 1000; // 1 min
@ -605,8 +612,8 @@ struct ObPlanStat
// following fields will be used for plan set memory management
PreCalcExprHandler* pre_cal_expr_handler_; //the handler that pre-calculable expression holds
common::hash::ObHashMap<ObAddr, int64_t> expected_worker_map_; // px 全局预期分配线程数
common::hash::ObHashMap<ObAddr, int64_t> minimal_worker_map_; // global minial threads required for query
AddrMap expected_worker_map_; // px 全局预期分配线程数
AddrMap minimal_worker_map_; // global minial threads required for query
uint64_t plan_hash_value_;
common::ObString outline_data_;
common::ObString hints_info_;