BiteTheDDDDt commented on code in PR #62646:
URL: https://github.com/apache/doris/pull/62646#discussion_r3124135384
##########
be/src/exec/scan/scanner_scheduler.cpp:
##########
@@ -156,29 +156,30 @@ void
ScannerScheduler::_scanner_scan(std::shared_ptr<ScannerContext> ctx,
// we set and get counter according below order, to make sure the counter
is updated before get_block, and the time of get_block is recorded in the
counter.
// 1. update_wait_worker_timer to make sure the time of waiting for worker
thread is recorded in the timer
// 2. start_scan_cpu_timer to make sure the cpu timer include the time of
open and get_block, which is the real cpu time of scanner
- // 3. update_scan_cpu_timer when defer, to make sure the cpu timer include
the time of open and get_block, which is the real cpu time of scanner
+ // 3. update_scan_cpu_timer at exit (in the Defer below for the non-eos
yield path,
+ // in the explicit eos block at the end of this function for the eos /
error path),
+ // to make sure the cpu timer includes the time of open and get_block,
which is the real cpu time of scanner
// 4. start_wait_worker_timer when defer, to make sure the time of waiting
for worker thread is recorded in the timer
MonotonicStopWatch max_run_time_watch;
max_run_time_watch.start();
scanner->update_wait_worker_timer();
scanner->start_scan_cpu_timer();
- bool need_update_profile = true;
auto update_scanner_profile = [&]() {
- if (need_update_profile) {
- scanner->update_scan_cpu_timer();
- scanner->update_realtime_counters();
- need_update_profile = false;
- }
+ scanner->update_scan_cpu_timer();
+ scanner->update_realtime_counters();
};
Status status = Status::OK();
bool eos = false;
Defer defer_scanner([&] {
if (status.ok() && !eos) {
- // if status is not ok, it means the scanner is failed, and the
counter may be not updated correctly, so no need to update counter again. if
eos is true, it means the scanner is finished successfully, and the counter is
updated correctly, so no need to update counter again.
+ // Only start wait worker timer when the scanner will be
re-submitted to the thread
+ // pool. When status is not ok or eos is true, the scanner is done
and won't be
+ // re-scheduled, so there is no "waiting for worker" phase to
track.
scanner->start_wait_worker_timer();
+ update_scanner_profile();
Review Comment:
虽然确实存在潜在问题,不过我觉得真实发生的概率非常低。而且这里需要统计到push_back_scan_task的时间,所以必须放defer里
##########
be/src/exec/scan/scanner_scheduler.cpp:
##########
@@ -156,29 +156,30 @@ void
ScannerScheduler::_scanner_scan(std::shared_ptr<ScannerContext> ctx,
// we set and get counter according below order, to make sure the counter
is updated before get_block, and the time of get_block is recorded in the
counter.
// 1. update_wait_worker_timer to make sure the time of waiting for worker
thread is recorded in the timer
// 2. start_scan_cpu_timer to make sure the cpu timer include the time of
open and get_block, which is the real cpu time of scanner
- // 3. update_scan_cpu_timer when defer, to make sure the cpu timer include
the time of open and get_block, which is the real cpu time of scanner
+ // 3. update_scan_cpu_timer at exit (in the Defer below for the non-eos
yield path,
+ // in the explicit eos block at the end of this function for the eos /
error path),
+ // to make sure the cpu timer includes the time of open and get_block,
which is the real cpu time of scanner
// 4. start_wait_worker_timer when defer, to make sure the time of waiting
for worker thread is recorded in the timer
MonotonicStopWatch max_run_time_watch;
max_run_time_watch.start();
scanner->update_wait_worker_timer();
scanner->start_scan_cpu_timer();
- bool need_update_profile = true;
auto update_scanner_profile = [&]() {
- if (need_update_profile) {
- scanner->update_scan_cpu_timer();
- scanner->update_realtime_counters();
- need_update_profile = false;
- }
+ scanner->update_scan_cpu_timer();
+ scanner->update_realtime_counters();
};
Status status = Status::OK();
bool eos = false;
Defer defer_scanner([&] {
if (status.ok() && !eos) {
- // if status is not ok, it means the scanner is failed, and the
counter may be not updated correctly, so no need to update counter again. if
eos is true, it means the scanner is finished successfully, and the counter is
updated correctly, so no need to update counter again.
+ // Only start wait worker timer when the scanner will be
re-submitted to the thread
+ // pool. When status is not ok or eos is true, the scanner is done
and won't be
+ // re-scheduled, so there is no "waiting for worker" phase to
track.
scanner->start_wait_worker_timer();
+ update_scanner_profile();
Review Comment:
虽然确实存在潜在问题,不过我觉得真实发生的概率非常低。而且这里需要统计到push_back_scan_task的时间,所以必须放defer里
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]