Occupation for memory optimization of das large result sets

This commit is contained in:
Azipro
2024-11-23 22:50:06 +00:00
committed by ob-robot
parent b55e7ef35c
commit a1d4438b40
2 changed files with 65 additions and 15 deletions

View File

@ -45,6 +45,8 @@ using namespace storage;
using namespace transaction;
namespace sql
{
OB_SERIALIZE_MEMBER(ObDASTCBMemProfileKey, fake_unique_id_, timestamp_);
OB_SERIALIZE_MEMBER(ObDASScanCtDef, // FARM COMPAT WHITELIST
ref_table_id_,
access_column_ids_,
@ -94,8 +96,9 @@ OB_DEF_SERIALIZE(ObDASScanRtDef)
ss_key_ranges_,
task_count_,
scan_op_id_,
scan_rows_,
row_width_);
scan_rows_size_,
row_width_,
das_tasks_key_);
return ret;
}
@ -121,8 +124,9 @@ OB_DEF_DESERIALIZE(ObDASScanRtDef)
ss_key_ranges_,
task_count_,
scan_op_id_,
scan_rows_,
row_width_);
scan_rows_size_,
row_width_,
das_tasks_key_);
if (OB_SUCC(ret)) {
(void)ObSQLUtils::adjust_time_by_ntp_offset(timeout_ts_);
}
@ -151,8 +155,9 @@ OB_DEF_SERIALIZE_SIZE(ObDASScanRtDef)
ss_key_ranges_,
task_count_,
scan_op_id_,
scan_rows_,
row_width_);
scan_rows_size_,
row_width_,
das_tasks_key_);
return len;
}

View File

@ -27,6 +27,49 @@ namespace sql
class ObDASExtraData;
class ObLocalIndexLookupOp;
struct ObDASTCBMemProfileKey {
ObDASTCBMemProfileKey()
: fake_unique_id_(0), timestamp_(0) {}
explicit ObDASTCBMemProfileKey(const ObDASTCBMemProfileKey &key)
: fake_unique_id_(key.fake_unique_id_), timestamp_(key.timestamp_) {}
void init(uint64_t timestamp, int64_t thread_id, int64_t op_id) {
timestamp_ = timestamp;
// [op_id (32bit), thread_id (32bit)]
fake_unique_id_ = (((uint64_t)op_id) << 32) | ((uint64_t)0xffffffff & thread_id);
}
void reset() {
fake_unique_id_ = 0;
timestamp_ = 0;
}
inline uint64_t hash() const
{
uint64_t hash_val = 0;
hash_val = common::murmurhash(&fake_unique_id_, sizeof(uint64_t), 0);
hash_val = common::murmurhash(&timestamp_, sizeof(uint64_t), hash_val);
return hash_val;
}
int hash(int64_t &hash_val) const { hash_val = hash(); return OB_SUCCESS; }
inline bool operator==(const ObDASTCBMemProfileKey& key) const
{
return fake_unique_id_ == key.fake_unique_id_ && timestamp_ == key.timestamp_;
}
inline bool is_valid() {
return (fake_unique_id_ > 0) && (timestamp_ > 0);
}
uint64_t fake_unique_id_;
uint64_t timestamp_;
TO_STRING_KV(K(fake_unique_id_), K(timestamp_));
OB_UNIS_VERSION(1);
};
struct ObDASScanCtDef : ObDASBaseCtDef
{
OB_UNIS_VERSION(1);
@ -167,9 +210,10 @@ public:
ss_key_ranges_(),
mbr_filters_(),
task_count_(1),
scan_op_id_(OB_INVALID_ID),
scan_rows_(OB_INVALID_ID),
row_width_(OB_INVALID_ID)
scan_op_id_(common::OB_INVALID_ID),
scan_rows_size_(common::OB_INVALID_ID),
row_width_(common::OB_INVALID_ID),
das_tasks_key_()
{ }
virtual ~ObDASScanRtDef();
@ -191,10 +235,9 @@ public:
K_(key_ranges),
K_(ss_key_ranges),
K_(mbr_filters),
K_(task_count),
K_(scan_op_id),
K_(scan_rows),
K_(row_width));
K_(scan_rows_size),
K_(das_tasks_key));
int init_pd_op(ObExecContext &exec_ctx, const ObDASScanCtDef &scan_ctdef);
storage::ObRow2ExprsProjector *p_row2exprs_projector_;
@ -220,10 +263,12 @@ public:
common::ObSEArray<common::ObNewRange, 1> key_ranges_;
common::ObSEArray<common::ObNewRange, 1> ss_key_ranges_;
common::ObSEArray<common::ObSpatialMBR, 1> mbr_filters_;
int64_t task_count_;
int64_t task_count_; // no use
uint64_t scan_op_id_;
int64_t scan_rows_;
int64_t row_width_;
int64_t scan_rows_size_;
int64_t row_width_; // no use
ObDASTCBMemProfileKey das_tasks_key_;
private:
union {
storage::ObRow2ExprsProjector row2exprs_projector_;