This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new af50461211 [fix](statistics) fix CpuTimeMS in audit log when
enable_vectorized_engine=true. (#14853)
af50461211 is described below
commit af50461211a99481973c43f3a442745c47e286be
Author: wxy <[email protected]>
AuthorDate: Fri Dec 9 21:13:05 2022 +0800
[fix](statistics) fix CpuTimeMS in audit log when
enable_vectorized_engine=true. (#14853)
Co-authored-by: [email protected] <[email protected]>
---
be/src/vec/exec/scan/new_olap_scan_node.cpp | 1 +
be/src/vec/exec/scan/scanner_scheduler.cpp | 6 ++----
be/src/vec/exec/scan/vscan_node.cpp | 1 +
be/src/vec/exec/scan/vscan_node.h | 1 +
be/src/vec/exec/scan/vscanner.cpp | 1 +
be/src/vec/exec/scan/vscanner.h | 10 ++++++++++
6 files changed, 16 insertions(+), 4 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 519205f3ea..07e933c4ad 100644
--- a/be/src/vec/exec/scan/new_olap_scan_node.cpp
+++ b/be/src/vec/exec/scan/new_olap_scan_node.cpp
@@ -41,6 +41,7 @@ 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);
return Status::OK();
}
diff --git a/be/src/vec/exec/scan/scanner_scheduler.cpp
b/be/src/vec/exec/scan/scanner_scheduler.cpp
index 38e322b83e..f2170a9599 100644
--- a/be/src/vec/exec/scan/scanner_scheduler.cpp
+++ b/be/src/vec/exec/scan/scanner_scheduler.cpp
@@ -182,10 +182,7 @@ void ScannerScheduler::_scanner_scan(ScannerScheduler*
scheduler, ScannerContext
SCOPED_CONSUME_MEM_TRACKER(scanner->runtime_state()->scanner_mem_tracker());
Thread::set_self_name("_scanner_scan");
scanner->update_wait_worker_timer();
- // Do not use ScopedTimer. There is no guarantee that, the counter
- // (_scan_cpu_timer, the class member) is not destroyed after
`_running_thread==0`.
- ThreadCpuStopWatch cpu_watch;
- cpu_watch.start();
+ scanner->start_scan_cpu_timer();
Status status = Status::OK();
bool eos = false;
RuntimeState* state = ctx->state();
@@ -270,6 +267,7 @@ void ScannerScheduler::_scanner_scan(ScannerScheduler*
scheduler, ScannerContext
ctx->append_blocks_to_queue(blocks);
}
+ scanner->update_scan_cpu_timer();
if (eos || should_stop) {
scanner->mark_to_need_to_close();
}
diff --git a/be/src/vec/exec/scan/vscan_node.cpp
b/be/src/vec/exec/scan/vscan_node.cpp
index e44a387859..9db08c937c 100644
--- a/be/src/vec/exec/scan/vscan_node.cpp
+++ b/be/src/vec/exec/scan/vscan_node.cpp
@@ -160,6 +160,7 @@ Status VScanNode::_init_profile() {
runtime_profile()->add_child(_scanner_profile.get(), true, nullptr);
_scan_timer = ADD_TIMER(_scanner_profile, "ScannerGetBlockTime");
+ _scan_cpu_timer = ADD_TIMER(_scanner_profile, "ScannerCpuTime");
_prefilter_timer = ADD_TIMER(_scanner_profile, "ScannerPrefilterTime");
_convert_block_timer = ADD_TIMER(_scanner_profile,
"ScannerConvertBlockTime");
_filter_timer = ADD_TIMER(_scanner_profile, "ScannerFilterTime");
diff --git a/be/src/vec/exec/scan/vscan_node.h
b/be/src/vec/exec/scan/vscan_node.h
index 46f4958ee6..3e6132bc29 100644
--- a/be/src/vec/exec/scan/vscan_node.h
+++ b/be/src/vec/exec/scan/vscan_node.h
@@ -244,6 +244,7 @@ protected:
RuntimeProfile::Counter* _acquire_runtime_filter_timer = nullptr;
// time of get block from scanner
RuntimeProfile::Counter* _scan_timer = nullptr;
+ RuntimeProfile::Counter* _scan_cpu_timer = nullptr;
// time of prefilter input block from scanner
RuntimeProfile::Counter* _prefilter_timer = nullptr;
// time of convert input block to output block from scanner
diff --git a/be/src/vec/exec/scan/vscanner.cpp
b/be/src/vec/exec/scan/vscanner.cpp
index 20e2a882c4..9a8b2858a4 100644
--- a/be/src/vec/exec/scan/vscanner.cpp
+++ b/be/src/vec/exec/scan/vscanner.cpp
@@ -120,6 +120,7 @@ Status VScanner::close(RuntimeState* state) {
}
void VScanner::_update_counters_before_close() {
+ COUNTER_UPDATE(_parent->_scan_cpu_timer, _scan_cpu_timer);
if (!_state->enable_profile() && !_is_load) return;
COUNTER_UPDATE(_parent->_rows_read_counter, _num_rows_read);
// Update stats for load
diff --git a/be/src/vec/exec/scan/vscanner.h b/be/src/vec/exec/scan/vscanner.h
index bc7a203c6d..8e8c8a837f 100644
--- a/be/src/vec/exec/scan/vscanner.h
+++ b/be/src/vec/exec/scan/vscanner.h
@@ -73,8 +73,15 @@ public:
_watch.start();
}
+ void start_scan_cpu_timer() {
+ _cpu_watch.reset();
+ _cpu_watch.start();
+ }
+
void update_wait_worker_timer() { _scanner_wait_worker_timer +=
_watch.elapsed_time(); }
+ void update_scan_cpu_timer() { _scan_cpu_timer +=
_cpu_watch.elapsed_time(); }
+
RuntimeState* runtime_state() { return _state; }
bool is_open() { return _is_open; }
@@ -162,7 +169,10 @@ protected:
// watch to count the time wait for scanner thread
MonotonicStopWatch _watch;
+ // Do not use ScopedTimer. There is no guarantee that, the counter
+ ThreadCpuStopWatch _cpu_watch;
int64_t _scanner_wait_worker_timer = 0;
+ int64_t _scan_cpu_timer = 0;
// File formats based push down predicate
std::vector<ExprContext*> _conjunct_ctxs;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]