From d4928c60c8ab6d670f0e2e1135d8fef2bfaefaba Mon Sep 17 00:00:00 2001 From: zhangstar333 <87313068+zhangstar333@users.noreply.github.com> Date: Fri, 14 Apr 2023 18:20:19 +0800 Subject: [PATCH] [vectorized](profile) fix pipeline profile can't get result under more instances (#18525) when enable pipeline to true, and set instances > 1 because all scan nodes share the scanners, maybe get the profile of scan node is all empty now show all the scan nodes and remove some infos those that _num_scanners->value() == 0 --- be/src/vec/exec/scan/new_olap_scan_node.cpp | 13 ++++++++----- be/src/vec/exec/scan/vscan_node.cpp | 14 +++++++++++--- 2 files changed, 19 insertions(+), 8 deletions(-) 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 57f8d52e20..3021ae3437 100644 --- a/be/src/vec/exec/scan/new_olap_scan_node.cpp +++ b/be/src/vec/exec/scan/new_olap_scan_node.cpp @@ -42,22 +42,25 @@ NewOlapScanNode::NewOlapScanNode(ObjectPool* pool, const TPlanNode& tnode, Status NewOlapScanNode::collect_query_statistics(QueryStatistics* statistics) { RETURN_IF_ERROR(ExecNode::collect_query_statistics(statistics)); - statistics->add_scan_bytes(_read_compressed_counter->value()); - statistics->add_scan_rows(_raw_rows_counter->value()); - statistics->add_cpu_ms(_scan_cpu_timer->value() / NANOS_PER_MILLIS); + if (!_is_pipeline_scan || _should_create_scanner) { + statistics->add_scan_bytes(_read_compressed_counter->value()); + statistics->add_scan_rows(_raw_rows_counter->value()); + statistics->add_cpu_ms(_scan_cpu_timer->value() / NANOS_PER_MILLIS); + } return Status::OK(); } Status NewOlapScanNode::prepare(RuntimeState* state) { RETURN_IF_ERROR(VScanNode::prepare(state)); + // if you want to add some profile in scan node, even it have not new VScanner object + // could add here, not in the _init_profile() function + _tablet_counter = ADD_COUNTER(_runtime_profile, "TabletNum", TUnit::UNIT); return Status::OK(); } Status NewOlapScanNode::_init_profile() { RETURN_IF_ERROR(VScanNode::_init_profile()); - _tablet_counter = ADD_COUNTER(_runtime_profile, "TabletNum", TUnit::UNIT); - // 1. init segment profile _segment_profile.reset(new RuntimeProfile("SegmentIterator")); _scanner_profile->add_child(_segment_profile.get(), true, nullptr); diff --git a/be/src/vec/exec/scan/vscan_node.cpp b/be/src/vec/exec/scan/vscan_node.cpp index 191091d6ed..22378d2744 100644 --- a/be/src/vec/exec/scan/vscan_node.cpp +++ b/be/src/vec/exec/scan/vscan_node.cpp @@ -82,7 +82,6 @@ Status VScanNode::init(const TPlanNode& tnode, RuntimeState* state) { } RETURN_IF_ERROR(_register_runtime_filter()); - RETURN_IF_ERROR(_init_profile()); return Status::OK(); } @@ -109,6 +108,17 @@ Status VScanNode::prepare(RuntimeState* state) { } } + // 1: running at not pipeline mode will init profile. + // 2: the scan node should create scanner at pipeline mode will init profile. + // during pipeline mode with more instances, olap scan node maybe not new VScanner object, + // so the profile of VScanner and SegmentIterator infos are always empty, could not init those. + if (!_is_pipeline_scan || _should_create_scanner) { + RETURN_IF_ERROR(_init_profile()); + } + // if you want to add some profile in scan node, even it have not new VScanner object + // could add here, not in the _init_profile() function + _get_next_timer = ADD_TIMER(_runtime_profile, "GetNextTime"); + _acquire_runtime_filter_timer = ADD_TIMER(_runtime_profile, "AcuireRuntimeFilterTime"); return Status::OK(); } @@ -224,8 +234,6 @@ Status VScanNode::_init_profile() { _total_throughput_counter = runtime_profile()->add_rate_counter("TotalReadThroughput", _rows_read_counter); _num_scanners = ADD_COUNTER(_runtime_profile, "NumScanners", TUnit::UNIT); - _get_next_timer = ADD_TIMER(_runtime_profile, "GetNextTime"); - _acquire_runtime_filter_timer = ADD_TIMER(_runtime_profile, "AcuireRuntimeFilterTime"); // 2. counters for scanners _scanner_profile.reset(new RuntimeProfile("VScanner"));