You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2024/09/13 07:02:26 UTC
(doris) branch spill_and_reserve updated: set min reserve bytes to 1MB (#40795)
This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch spill_and_reserve
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/spill_and_reserve by this push:
new 43c64397518 set min reserve bytes to 1MB (#40795)
43c64397518 is described below
commit 43c64397518f05419924768785ac51739e7924d1
Author: yiguolei <67...@qq.com>
AuthorDate: Fri Sep 13 15:02:19 2024 +0800
set min reserve bytes to 1MB (#40795)
## Proposed changes
Issue Number: close #xxx
<!--Describe your changes.-->
---------
Co-authored-by: yiguolei <yi...@gmail.com>
---
be/src/pipeline/exec/operator.h | 16 +++++++++++-----
be/src/pipeline/pipeline_task.cpp | 2 ++
be/src/runtime/runtime_state.h | 9 +++++++++
.../main/java/org/apache/doris/qe/SessionVariable.java | 8 ++++++++
gensrc/thrift/PaloInternalService.thrift | 3 +++
5 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/be/src/pipeline/exec/operator.h b/be/src/pipeline/exec/operator.h
index c6b49317375..4932504b424 100644
--- a/be/src/pipeline/exec/operator.h
+++ b/be/src/pipeline/exec/operator.h
@@ -114,6 +114,11 @@ public:
virtual size_t revocable_mem_size(RuntimeState* state) const { return 0; }
+ // If this method is not overwrite by child, its default value is 1MB
+ [[nodiscard]] virtual size_t get_reserve_mem_size(RuntimeState* state) {
+ return state->minimum_operator_memory_required_bytes();
+ }
+
virtual Status revoke_memory(RuntimeState* state) { return Status::OK(); }
[[nodiscard]] virtual bool require_data_distribution() const { return false; }
OperatorXPtr child_x() { return _child_x; }
@@ -557,8 +562,6 @@ public:
[[nodiscard]] std::string get_name() const override { return _name; }
- [[nodiscard]] virtual size_t get_reserve_mem_size(RuntimeState* state) { return 0; }
-
[[nodiscard]] virtual bool try_reserve_memory(RuntimeState* state, vectorized::Block* block,
bool eos) {
return true;
@@ -810,8 +813,6 @@ public:
void set_parallel_tasks(int parallel_tasks) { _parallel_tasks = parallel_tasks; }
int parallel_tasks() const { return _parallel_tasks; }
- [[nodiscard]] virtual size_t get_reserve_mem_size(RuntimeState* state) { return 0; }
-
virtual void reset_reserve_mem_size(RuntimeState* state) {}
protected:
@@ -875,8 +876,13 @@ public:
size_t get_reserve_mem_size(RuntimeState* state) override {
auto& local_state = get_local_state(state);
auto estimated_size = local_state.estimate_memory_usage();
+ if (estimated_size < state->minimum_operator_memory_required_bytes()) {
+ estimated_size = state->minimum_operator_memory_required_bytes();
+ }
if (!is_source() && _child_x) {
- estimated_size += _child_x->get_reserve_mem_size(state);
+ auto child_reserve_size = _child_x->get_reserve_mem_size(state);
+ estimated_size +=
+ std::max(state->minimum_operator_memory_required_bytes(), child_reserve_size);
}
return estimated_size;
}
diff --git a/be/src/pipeline/pipeline_task.cpp b/be/src/pipeline/pipeline_task.cpp
index e9ca84ea660..6c5e018d3ec 100644
--- a/be/src/pipeline/pipeline_task.cpp
+++ b/be/src/pipeline/pipeline_task.cpp
@@ -376,6 +376,8 @@ Status PipelineTask::execute(bool* eos) {
SCOPED_TIMER(_get_block_timer);
_get_block_counter->update(1);
size_t sink_reserve_size = _sink->get_reserve_mem_size(_state);
+ sink_reserve_size =
+ std::max(sink_reserve_size, _state->minimum_operator_memory_required_bytes());
reserve_size = _root->get_reserve_mem_size(_state) + sink_reserve_size;
_root->reset_reserve_mem_size(_state);
DCHECK_EQ(_root->get_reserve_mem_size(_state), 0);
diff --git a/be/src/runtime/runtime_state.h b/be/src/runtime/runtime_state.h
index 442268850bf..299d0204838 100644
--- a/be/src/runtime/runtime_state.h
+++ b/be/src/runtime/runtime_state.h
@@ -583,6 +583,15 @@ public:
return 1;
}
+ size_t minimum_operator_memory_required_bytes() const {
+ if (_query_options.__isset.minimum_operator_memory_required_kb) {
+ return _query_options.minimum_operator_memory_required_kb * 1024;
+ } else {
+ // refer other database
+ return 100 * 1024;
+ }
+ }
+
void set_max_operator_id(int max_operator_id) { _max_operator_id = max_operator_id; }
int max_operator_id() const { return _max_operator_id; }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
index 4140835b657..37b8c4624d0 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
@@ -654,6 +654,8 @@ public class SessionVariable implements Serializable, Writable {
public static final String IN_LIST_VALUE_COUNT_THRESHOLD = "in_list_value_count_threshold";
+ public static final String MINIMUM_OPERATOR_MEMORY_REQUIRED_KB = "minimum_operator_memory_required_kb";
+
/**
* If set false, user couldn't submit analyze SQL and FE won't allocate any related resources.
*/
@@ -1929,6 +1931,11 @@ public class SessionVariable implements Serializable, Writable {
description = {"对外表启用 count(*) 下推优化", "enable count(*) pushdown optimization for external table"})
private boolean enableCountPushDownForExternalTable = true;
+ @VariableMgr.VarAttr(name = MINIMUM_OPERATOR_MEMORY_REQUIRED_KB, needForward = true,
+ description = {"一个算子运行需要的最小的内存大小",
+ "The minimum memory required to be used by an operator, if not meet, the operator will not run"})
+ public int minimumOperatorMemoryRequiredKB = 1000;
+
public static final String IGNORE_RUNTIME_FILTER_IDS = "ignore_runtime_filter_ids";
public Set<Integer> getIgnoredRuntimeFilterIds() {
@@ -3701,6 +3708,7 @@ public class SessionVariable implements Serializable, Writable {
tResult.setEnableSegmentCache(enableSegmentCache);
tResult.setInListValueCountThreshold(inListValueCountThreshold);
+ tResult.setMinimumOperatorMemoryRequiredKb(minimumOperatorMemoryRequiredKB);
return tResult;
}
diff --git a/gensrc/thrift/PaloInternalService.thrift b/gensrc/thrift/PaloInternalService.thrift
index 85e4ade4ca4..51cf3d54f2d 100644
--- a/gensrc/thrift/PaloInternalService.thrift
+++ b/gensrc/thrift/PaloInternalService.thrift
@@ -335,6 +335,9 @@ struct TQueryOptions {
127: optional i32 in_list_value_count_threshold = 10;
+ // The minimum memory that an operator required to run.
+ 128: optional i32 minimum_operator_memory_required_kb = 1000;
+
// For cloud, to control if the content would be written into file cache
// In write path, to control if the content would be written into file cache.
// In read path, read from file cache or remote storage when execute query.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org