github-actions[bot] commented on code in PR #32641:
URL: https://github.com/apache/doris/pull/32641#discussion_r1542541083
##########
be/src/pipeline/pipeline_x/pipeline_x_task.cpp:
##########
@@ -326,6 +304,47 @@ Status PipelineXTask::execute(bool* eos) {
return status;
}
+bool PipelineXTask::should_revoke_memory(RuntimeState* state, int64_t
revocable_mem_bytes) {
+ auto* query_ctx = state->get_query_ctx();
+ bool need_revoke = query_ctx->need_revoke();
+ if (!need_revoke) {
+ return false;
+ }
+
+ const auto min_revocable_mem_bytes = state->min_revocable_mem();
+
+ auto wg = query_ctx->workload_group();
+ if (!wg) {
+ LOG_ONCE(INFO) << "no workload group for query " <<
print_id(state->query_id());
+ return false;
+ }
+ bool is_wg_mem_low_water_mark = false;
+ bool is_wg_mem_high_water_mark = false;
+ wg->check_mem_used(&is_wg_mem_low_water_mark, &is_wg_mem_high_water_mark);
+ if (is_wg_mem_high_water_mark) {
+ if (revocable_mem_bytes > 0) {
+ LOG_EVERY_N(INFO, 5) << "revoke memory, hight water mark";
+ return true;
Review Comment:
warning: redundant boolean literal in conditional return statement
[readability-simplify-boolean-expr]
be/src/pipeline/pipeline_x/pipeline_x_task.cpp:324:
```diff
- if (revocable_mem_bytes > 0) {
- LOG_EVERY_N(INFO, 5) << "revoke memory, hight water mark";
- return true;
- }
- return false;
+ return revocable_mem_bytes > 0;
```
##########
be/src/runtime/workload_group/workload_group_manager.cpp:
##########
@@ -135,6 +137,135 @@ void
WorkloadGroupMgr::delete_workload_group_by_ids(std::set<uint64_t> used_wg_i
<< "ms, deleted group size:" << deleted_task_groups.size();
}
+struct WorkloadGroupMemInfo {
+ int64_t total_mem_used = 0;
+ int64_t weighted_mem_used = 0;
+ bool is_low_wartermark = false;
+ bool is_high_wartermark = false;
+ double mem_used_ratio = 0;
+};
+void WorkloadGroupMgr::refresh_wg_memory_info() {
Review Comment:
warning: function 'refresh_wg_memory_info' exceeds recommended
size/complexity thresholds [readability-function-size]
```cpp
void WorkloadGroupMgr::refresh_wg_memory_info() {
^
```
<details>
<summary>Additional context</summary>
**be/src/runtime/workload_group/workload_group_manager.cpp:146:** 120 lines
including whitespace and comments (threshold 80)
```cpp
void WorkloadGroupMgr::refresh_wg_memory_info() {
^
```
</details>
##########
be/src/runtime/query_context.h:
##########
@@ -247,6 +247,32 @@ class QueryContext {
bool is_nereids() const { return _is_nereids; }
+ WorkloadGroupPtr workload_group() const { return _workload_group; }
+
+ void inc_running_big_mem_op_num() {
+ _running_big_mem_op_num.fetch_add(1, std::memory_order_relaxed);
+ }
+ void dec_running_big_mem_op_num() {
+ _running_big_mem_op_num.fetch_sub(1, std::memory_order_relaxed);
+ }
+ int32_t get_running_big_mem_op_num() {
+ return _running_big_mem_op_num.load(std::memory_order_relaxed);
+ }
+
+ void set_weighted_mem(int64_t weighted_limit, int64_t
weighted_consumption) {
+ std::lock_guard<std::mutex> l(_weighted_mem_lock);
+ _weighted_consumption = weighted_consumption;
+ _weighted_limit = weighted_limit;
+ }
+ void get_weighted_mem_info(int64_t& weighted_limit, int64_t&
weighted_consumption) {
Review Comment:
warning: method 'get_weighted_mem_info' can be made const
[readability-make-member-function-const]
```suggestion
void get_weighted_mem_info(int64_t& weighted_limit, int64_t&
weighted_consumption) const {
```
##########
be/src/runtime/workload_group/workload_group.h:
##########
@@ -97,7 +121,7 @@
return _memory_limit > 0;
}
- Status add_query(TUniqueId query_id) {
+ Status add_query(TUniqueId query_id, std::shared_ptr<QueryContext>
query_ctx) {
Review Comment:
warning: method 'add_query' can be made const
[readability-make-member-function-const]
```suggestion
Status add_query(TUniqueId query_id, std::shared_ptr<QueryContext>
query_ctx) const {
```
##########
be/src/runtime/workload_group/workload_group.h:
##########
@@ -82,6 +83,29 @@ class WorkloadGroup : public
std::enable_shared_from_this<WorkloadGroup> {
int64_t memory_used();
+ int spill_threshold_low_water_mark() const {
+ return _spill_low_watermark.load(std::memory_order_relaxed);
+ }
+ int spill_threashold_high_water_mark() const {
+ return _spill_high_watermark.load(std::memory_order_relaxed);
+ }
+
+ void set_weighted_memory_used(int64_t wg_total_mem_used, double ratio);
+
+ int64_t get_weighted_memory_used() {
+ return _weighted_mem_used.load(std::memory_order_relaxed);
+ }
+
+ void check_mem_used(bool* is_low_wartermark, bool* is_high_wartermark)
const {
Review Comment:
warning: method 'check_mem_used' can be made static
[readability-convert-member-functions-to-static]
```suggestion
static void check_mem_used(bool* is_low_wartermark, bool*
is_high_wartermark) {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]