[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
This commit is contained in:
zhangstar333
2023-04-14 18:20:19 +08:00
committed by GitHub
parent 4cde3d4f21
commit d4928c60c8
2 changed files with 19 additions and 8 deletions

View File

@ -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);

View File

@ -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"));