diff --git a/be/src/pipeline/exec/olap_scan_operator.cpp b/be/src/pipeline/exec/olap_scan_operator.cpp index 059f961501..2f22daa519 100644 --- a/be/src/pipeline/exec/olap_scan_operator.cpp +++ b/be/src/pipeline/exec/olap_scan_operator.cpp @@ -127,6 +127,7 @@ Status OlapScanLocalState::_init_profile() { _filtered_segment_counter = ADD_COUNTER(_segment_profile, "NumSegmentFiltered", TUnit::UNIT); _total_segment_counter = ADD_COUNTER(_segment_profile, "NumSegmentTotal", TUnit::UNIT); _tablet_counter = ADD_COUNTER(_runtime_profile, "TabletNum", TUnit::UNIT); + _runtime_filter_info = ADD_LABEL_COUNTER_WITH_LEVEL(_runtime_profile, "RuntimeFilterInfo", 1); return Status::OK(); } @@ -477,6 +478,16 @@ void OlapScanLocalState::add_filter_info(int id, const PredicateFilterInfo& upda // add info _segment_profile->add_info_string(filter_name, info_str); + + const std::string rf_name = "filter id = " + std::to_string(id) + " "; + + // add counter + auto* input_count = ADD_CHILD_COUNTER_WITH_LEVEL(_runtime_profile, rf_name + "input", + TUnit::UNIT, "RuntimeFilterInfo", 1); + auto* filtered_count = ADD_CHILD_COUNTER_WITH_LEVEL(_runtime_profile, rf_name + "filtered", + TUnit::UNIT, "RuntimeFilterInfo", 1); + COUNTER_UPDATE(input_count, info.input_row); + COUNTER_UPDATE(filtered_count, info.filtered_row); } OlapScanOperatorX::OlapScanOperatorX(ObjectPool* pool, const TPlanNode& tnode, int operator_id, diff --git a/be/src/pipeline/exec/olap_scan_operator.h b/be/src/pipeline/exec/olap_scan_operator.h index 0527fa6f44..1f0fac55a4 100644 --- a/be/src/pipeline/exec/olap_scan_operator.h +++ b/be/src/pipeline/exec/olap_scan_operator.h @@ -175,6 +175,8 @@ private: // total number of segment related to this scan node RuntimeProfile::Counter* _total_segment_counter = nullptr; + RuntimeProfile::Counter* _runtime_filter_info = nullptr; + std::mutex _profile_mtx; }; diff --git a/be/src/util/runtime_profile.h b/be/src/util/runtime_profile.h index fbddb9dc4e..d5233d40f2 100644 --- a/be/src/util/runtime_profile.h +++ b/be/src/util/runtime_profile.h @@ -51,6 +51,8 @@ class TRuntimeProfileTree; #define MACRO_CONCAT(x, y) CONCAT_IMPL(x, y) #define ADD_LABEL_COUNTER(profile, name) (profile)->add_counter(name, TUnit::NONE) +#define ADD_LABEL_COUNTER_WITH_LEVEL(profile, name, type) \ + (profile)->add_counter_with_level(name, TUnit::NONE, type) #define ADD_COUNTER(profile, name, type) (profile)->add_counter(name, type) #define ADD_COUNTER_WITH_LEVEL(profile, name, type, level) \ (profile)->add_counter_with_level(name, type, level) diff --git a/be/src/vec/exec/scan/new_olap_scan_node.cpp b/be/src/vec/exec/scan/new_olap_scan_node.cpp index be06280d79..8c67acc191 100644 --- a/be/src/vec/exec/scan/new_olap_scan_node.cpp +++ b/be/src/vec/exec/scan/new_olap_scan_node.cpp @@ -193,6 +193,7 @@ Status NewOlapScanNode::_init_profile() { _filtered_segment_counter = ADD_COUNTER(_segment_profile, "NumSegmentFiltered", TUnit::UNIT); _total_segment_counter = ADD_COUNTER(_segment_profile, "NumSegmentTotal", TUnit::UNIT); + _runtime_filter_info = ADD_LABEL_COUNTER_WITH_LEVEL(_runtime_profile, "RuntimeFilterInfo", 1); return Status::OK(); } @@ -718,6 +719,16 @@ void NewOlapScanNode::add_filter_info(int id, const PredicateFilterInfo& update_ // add info _segment_profile->add_info_string(filter_name, info_str); + + const std::string rf_name = "filter id = " + std::to_string(id) + " "; + + // add counter + auto* input_count = ADD_CHILD_COUNTER_WITH_LEVEL(_runtime_profile, rf_name + "input", + TUnit::UNIT, "RuntimeFilterInfo", 1); + auto* filtered_count = ADD_CHILD_COUNTER_WITH_LEVEL(_runtime_profile, rf_name + "filtered", + TUnit::UNIT, "RuntimeFilterInfo", 1); + COUNTER_UPDATE(input_count, info.input_row); + COUNTER_UPDATE(filtered_count, info.filtered_row); } }; // namespace doris::vectorized diff --git a/be/src/vec/exec/scan/new_olap_scan_node.h b/be/src/vec/exec/scan/new_olap_scan_node.h index 06b68497b5..c62e7028cd 100644 --- a/be/src/vec/exec/scan/new_olap_scan_node.h +++ b/be/src/vec/exec/scan/new_olap_scan_node.h @@ -202,6 +202,8 @@ private: RuntimeProfile::Counter* _output_index_result_column_timer = nullptr; + RuntimeProfile::Counter* _runtime_filter_info = nullptr; + // number of segment filtered by column stat when creating seg iterator RuntimeProfile::Counter* _filtered_segment_counter = nullptr; // total number of segment related to this scan node diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/util/AggCounter.java b/fe/fe-core/src/main/java/org/apache/doris/common/util/AggCounter.java index d7eb718495..69380e1454 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/util/AggCounter.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/AggCounter.java @@ -35,6 +35,9 @@ public class AggCounter extends Counter { } public void addCounter(Counter counter) { + if (counter == null) { + return; + } if (number == 0) { max.setValue(counter.getValue()); sum.setValue(counter.getValue()); diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/util/RuntimeProfile.java b/fe/fe-core/src/main/java/org/apache/doris/common/util/RuntimeProfile.java index 251e6417fb..080336871d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/util/RuntimeProfile.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/RuntimeProfile.java @@ -484,19 +484,18 @@ public class RuntimeProfile { } } - private static void mergeCounters(String counterName, List profiles, + private static void mergeCounters(String parentCounterName, List profiles, RuntimeProfile simpleProfile) { if (profiles.size() == 0) { return; } RuntimeProfile templateProfile = profiles.get(0); - Set childCounterSet = templateProfile.childCounterMap.get(counterName); + Set childCounterSet = templateProfile.childCounterMap.get(parentCounterName); if (childCounterSet == null) { return; } for (String childCounterName : childCounterSet) { Counter counter = templateProfile.counterMap.get(childCounterName); - mergeCounters(childCounterName, profiles, simpleProfile); if (counter.getLevel() == 1) { Counter oldCounter = profiles.get(0).counterMap.get(childCounterName); AggCounter aggCounter = new AggCounter(oldCounter.getType()); @@ -504,8 +503,13 @@ public class RuntimeProfile { Counter orgCounter = profile.counterMap.get(childCounterName); aggCounter.addCounter(orgCounter); } - simpleProfile.addCounter(childCounterName, aggCounter, ROOT_COUNTER); + if (simpleProfile.counterMap.containsKey(parentCounterName)) { + simpleProfile.addCounter(childCounterName, aggCounter, parentCounterName); + } else { + simpleProfile.addCounter(childCounterName, aggCounter, ROOT_COUNTER); + } } + mergeCounters(childCounterName, profiles, simpleProfile); } }