This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new f579eceb344 [Improvementation](profile) add some profile on 
vcollect_iterator (#32794)
f579eceb344 is described below

commit f579eceb344d62206a417e521dc9e42e6668f821
Author: Pxl <[email protected]>
AuthorDate: Tue Mar 26 10:54:13 2024 +0800

    [Improvementation](profile) add some profile on vcollect_iterator (#32794)
    
    add some profile on vcollect_iterator
---
 be/src/olap/olap_common.h                   | 3 +++
 be/src/pipeline/exec/olap_scan_operator.cpp | 2 ++
 be/src/pipeline/exec/olap_scan_operator.h   | 2 ++
 be/src/vec/exec/scan/new_olap_scan_node.cpp | 2 ++
 be/src/vec/exec/scan/new_olap_scan_node.h   | 2 ++
 be/src/vec/exec/scan/new_olap_scanner.cpp   | 5 +++++
 be/src/vec/exec/scan/vscanner.cpp           | 6 +++---
 be/src/vec/olap/vcollect_iterator.cpp       | 8 ++++++--
 be/src/vec/olap/vcollect_iterator.h         | 2 +-
 9 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/be/src/olap/olap_common.h b/be/src/olap/olap_common.h
index c08705861df..27a71a56b14 100644
--- a/be/src/olap/olap_common.h
+++ b/be/src/olap/olap_common.h
@@ -369,6 +369,9 @@ struct OlapReaderStatistics {
 
     io::FileCacheStatistics file_cache_stats;
     int64_t load_segments_timer = 0;
+
+    int64_t collect_iterator_merge_next_timer = 0;
+    int64_t collect_iterator_normal_next_timer = 0;
 };
 
 using ColumnId = uint32_t;
diff --git a/be/src/pipeline/exec/olap_scan_operator.cpp 
b/be/src/pipeline/exec/olap_scan_operator.cpp
index 0aab714449e..6ec6734243c 100644
--- a/be/src/pipeline/exec/olap_scan_operator.cpp
+++ b/be/src/pipeline/exec/olap_scan_operator.cpp
@@ -64,6 +64,8 @@ Status OlapScanLocalState::_init_profile() {
     _block_conditions_filtered_timer = ADD_TIMER(_segment_profile, 
"BlockConditionsFilteredTime");
     _block_conditions_filtered_bf_timer =
             ADD_TIMER(_segment_profile, 
"BlockConditionsFilteredBloomFilterTime");
+    _collect_iterator_merge_next_timer = ADD_TIMER(_segment_profile, 
"CollectIteratorMergeTime");
+    _collect_iterator_normal_next_timer = ADD_TIMER(_segment_profile, 
"CollectIteratorNormalTime");
     _block_conditions_filtered_zonemap_timer =
             ADD_TIMER(_segment_profile, "BlockConditionsFilteredZonemapTime");
     _block_conditions_filtered_zonemap_rp_timer =
diff --git a/be/src/pipeline/exec/olap_scan_operator.h 
b/be/src/pipeline/exec/olap_scan_operator.h
index 233283a59aa..cc516780c09 100644
--- a/be/src/pipeline/exec/olap_scan_operator.h
+++ b/be/src/pipeline/exec/olap_scan_operator.h
@@ -144,6 +144,8 @@ private:
     RuntimeProfile::Counter* _block_init_seek_counter = nullptr;
     RuntimeProfile::Counter* _block_conditions_filtered_timer = nullptr;
     RuntimeProfile::Counter* _block_conditions_filtered_bf_timer = nullptr;
+    RuntimeProfile::Counter* _collect_iterator_merge_next_timer = nullptr;
+    RuntimeProfile::Counter* _collect_iterator_normal_next_timer = nullptr;
     RuntimeProfile::Counter* _block_conditions_filtered_zonemap_timer = 
nullptr;
     RuntimeProfile::Counter* _block_conditions_filtered_zonemap_rp_timer = 
nullptr;
     RuntimeProfile::Counter* _block_conditions_filtered_dict_timer = nullptr;
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 7473820abef..65b8326d665 100644
--- a/be/src/vec/exec/scan/new_olap_scan_node.cpp
+++ b/be/src/vec/exec/scan/new_olap_scan_node.cpp
@@ -113,6 +113,8 @@ Status NewOlapScanNode::_init_profile() {
     _block_conditions_filtered_timer = ADD_TIMER(_segment_profile, 
"BlockConditionsFilteredTime");
     _block_conditions_filtered_bf_timer =
             ADD_TIMER(_segment_profile, 
"BlockConditionsFilteredBloomFilterTime");
+    _collect_iterator_merge_next_timer = ADD_TIMER(_segment_profile, 
"CollectIteratorMergeTime");
+    _collect_iterator_normal_next_timer = ADD_TIMER(_segment_profile, 
"CollectIteratorNormalTime");
     _block_conditions_filtered_zonemap_timer =
             ADD_TIMER(_segment_profile, "BlockConditionsFilteredZonemapTime");
     _block_conditions_filtered_zonemap_rp_timer =
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 e1861a3b619..0094b0e78b9 100644
--- a/be/src/vec/exec/scan/new_olap_scan_node.h
+++ b/be/src/vec/exec/scan/new_olap_scan_node.h
@@ -169,6 +169,8 @@ private:
     RuntimeProfile::Counter* _block_init_seek_counter = nullptr;
     RuntimeProfile::Counter* _block_conditions_filtered_timer = nullptr;
     RuntimeProfile::Counter* _block_conditions_filtered_bf_timer = nullptr;
+    RuntimeProfile::Counter* _collect_iterator_merge_next_timer = nullptr;
+    RuntimeProfile::Counter* _collect_iterator_normal_next_timer = nullptr;
     RuntimeProfile::Counter* _block_conditions_filtered_zonemap_timer = 
nullptr;
     RuntimeProfile::Counter* _block_conditions_filtered_zonemap_rp_timer = 
nullptr;
     RuntimeProfile::Counter* _block_conditions_filtered_dict_timer = nullptr;
diff --git a/be/src/vec/exec/scan/new_olap_scanner.cpp 
b/be/src/vec/exec/scan/new_olap_scanner.cpp
index 88a8d842df9..e69cb94a0df 100644
--- a/be/src/vec/exec/scan/new_olap_scanner.cpp
+++ b/be/src/vec/exec/scan/new_olap_scanner.cpp
@@ -220,6 +220,9 @@ Status NewOlapScanner::init() {
 
 Status NewOlapScanner::open(RuntimeState* state) {
     RETURN_IF_ERROR(VScanner::open(state));
+    auto* timer = _parent ? ((NewOlapScanNode*)_parent)->_reader_init_timer
+                          : 
((pipeline::OlapScanLocalState*)_local_state)->_reader_init_timer;
+    SCOPED_TIMER(timer);
 
     auto res = _tablet_reader->init(_tablet_reader_params);
     if (!res.ok()) {
@@ -586,6 +589,8 @@ void NewOlapScanner::_collect_profile_before_close() {
     COUNTER_UPDATE(Parent->_block_conditions_filtered_timer, 
stats.block_conditions_filtered_ns); \
     COUNTER_UPDATE(Parent->_block_conditions_filtered_bf_timer,                
                   \
                    stats.block_conditions_filtered_bf_ns);                     
                   \
+    COUNTER_UPDATE(Parent->_collect_iterator_merge_next_timer,                 
                   \
+                   stats.collect_iterator_merge_next_timer);                   
                   \
     COUNTER_UPDATE(Parent->_block_conditions_filtered_zonemap_timer,           
                   \
                    stats.block_conditions_filtered_zonemap_ns);                
                   \
     COUNTER_UPDATE(Parent->_block_conditions_filtered_zonemap_rp_timer,        
                   \
diff --git a/be/src/vec/exec/scan/vscanner.cpp 
b/be/src/vec/exec/scan/vscanner.cpp
index 152547e8a02..39a9059d1d3 100644
--- a/be/src/vec/exec/scan/vscanner.cpp
+++ b/be/src/vec/exec/scan/vscanner.cpp
@@ -91,7 +91,7 @@ Status VScanner::get_block(RuntimeState* state, Block* block, 
bool* eof) {
     SCOPED_RAW_TIMER(&_per_scanner_timer);
     int64_t rows_read_threshold = _num_rows_read + 
config::doris_scanner_row_num;
     if (!block->mem_reuse()) {
-        for (const auto slot_desc : _output_tuple_desc->slots()) {
+        for (auto* const slot_desc : _output_tuple_desc->slots()) {
             if (!slot_desc->need_materialize()) {
                 // should be ignore from reading
                 continue;
@@ -112,7 +112,7 @@ Status VScanner::get_block(RuntimeState* state, Block* 
block, bool* eof) {
             // 1. Get input block from scanner
             {
                 // get block time
-                auto timer = _parent ? _parent->_scan_timer : 
_local_state->_scan_timer;
+                auto* timer = _parent ? _parent->_scan_timer : 
_local_state->_scan_timer;
                 SCOPED_TIMER(timer);
                 RETURN_IF_ERROR(_get_block_impl(state, block, eof));
                 if (*eof) {
@@ -125,7 +125,7 @@ Status VScanner::get_block(RuntimeState* state, Block* 
block, bool* eof) {
 
             // 2. Filter the output block finally.
             {
-                auto timer = _parent ? _parent->_filter_timer : 
_local_state->_filter_timer;
+                auto* timer = _parent ? _parent->_filter_timer : 
_local_state->_filter_timer;
                 SCOPED_TIMER(timer);
                 RETURN_IF_ERROR(_filter_output_block(block));
             }
diff --git a/be/src/vec/olap/vcollect_iterator.cpp 
b/be/src/vec/olap/vcollect_iterator.cpp
index d8728cfa812..90a38eef51e 100644
--- a/be/src/vec/olap/vcollect_iterator.cpp
+++ b/be/src/vec/olap/vcollect_iterator.cpp
@@ -22,6 +22,7 @@
 
 #include <algorithm>
 #include <iterator>
+#include <memory>
 #include <ostream>
 #include <set>
 #include <utility>
@@ -38,6 +39,7 @@
 #include "runtime/query_context.h"
 #include "runtime/runtime_predicate.h"
 #include "runtime/runtime_state.h"
+#include "util/runtime_profile.h"
 #include "vec/columns/column.h"
 #include "vec/core/column_with_type_and_name.h"
 #include "vec/core/field.h"
@@ -467,7 +469,7 @@ Status VCollectIterator::Level0Iterator::init(bool 
get_data_by_ref) {
     }
 
     auto st = refresh_current_row();
-    if (_get_data_by_ref && _block_view.size()) {
+    if (_get_data_by_ref && !_block_view.empty()) {
         _ref = _block_view[0];
     } else {
         _ref = {_block, 0, false};
@@ -664,7 +666,7 @@ Status VCollectIterator::Level1Iterator::init(bool 
get_data_by_ref) {
                 break;
             }
         }
-        _heap.reset(new MergeHeap {LevelIteratorComparator(sequence_loc, 
_is_reverse)});
+        _heap = 
std::make_unique<MergeHeap>(LevelIteratorComparator(sequence_loc, _is_reverse));
         for (auto&& child : _children) {
             DCHECK(child != nullptr);
             //DCHECK(child->current_row().ok());
@@ -770,6 +772,7 @@ Status 
VCollectIterator::Level1Iterator::_normal_next(IteratorRowRef* ref) {
 }
 
 Status VCollectIterator::Level1Iterator::_merge_next(Block* block) {
+    SCOPED_RAW_TIMER(&_reader->_stats.collect_iterator_merge_next_timer);
     int target_block_row = 0;
     auto target_columns = block->mutate_columns();
     size_t column_count = target_columns.size();
@@ -851,6 +854,7 @@ Status VCollectIterator::Level1Iterator::_merge_next(Block* 
block) {
 }
 
 Status VCollectIterator::Level1Iterator::_normal_next(Block* block) {
+    SCOPED_RAW_TIMER(&_reader->_stats.collect_iterator_normal_next_timer);
     auto res = _cur_child->next(block);
     if (LIKELY(res.ok())) {
         return Status::OK();
diff --git a/be/src/vec/olap/vcollect_iterator.h 
b/be/src/vec/olap/vcollect_iterator.h
index 06b17329163..e83f56559f4 100644
--- a/be/src/vec/olap/vcollect_iterator.h
+++ b/be/src/vec/olap/vcollect_iterator.h
@@ -187,7 +187,7 @@ private:
 
         Status init(bool get_data_by_ref = false) override;
 
-        virtual void init_for_union(bool get_data_by_ref) override;
+        void init_for_union(bool get_data_by_ref) override;
 
         /* For unique and agg, rows is aggregated in block_reader, which access
          * first row so we need prepare the first row ref while duplicated


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to