HappenLee commented on code in PR #24844:
URL: https://github.com/apache/doris/pull/24844#discussion_r1337989565


##########
be/src/vec/exec/scan/scanner_scheduler.cpp:
##########
@@ -447,9 +446,19 @@ void 
ScannerScheduler::_task_group_scanner_scan(ScannerScheduler* scheduler,
         auto success = scan_queue->take(&scan_task);
         if (success) {
             int64_t time_spent = 0;
-            {
-                SCOPED_RAW_TIMER(&time_spent);
-                scan_task.scan_func();
+            if (!scan_task.is_empty_task) {
+                RuntimeProfile::Counter tmp_timer(TUnit::TIME_NS);
+                {
+                    SCOPED_CPU_TIMER(&tmp_timer);
+                    scan_task.scan_func();
+                }
+                time_spent = tmp_timer.value();
+            } else {
+                {
+                    SCOPED_RAW_TIMER(&time_spent);

Review Comment:
   better use a new timer to register the sleep timer for the debug target



##########
be/src/vec/exec/scan/scan_task_queue.cpp:
##########
@@ -132,6 +205,31 @@ void ScanTaskTaskGroupQueue::update_tg_cpu_share(const 
taskgroup::TaskGroupInfo&
     }
 }
 
+void ScanTaskTaskGroupQueue::reset_empty_group_entity() {
+    int user_g_cpu_hard_limit = 0;
+    bool contains_empty_group = false;
+    for (auto* entity : _group_entities) {
+        if (!entity->is_empty_group_entity()) {
+            user_g_cpu_hard_limit += entity->cpu_share();
+        } else {
+            contains_empty_group = true;
+        }
+    }
+
+    // 0 <= user_g_cpu_hard_limit <= 100, bound by FE
+    // user_g_cpu_hard_limit = 0 means no group exists
+    int empty_group_cpu_share = 100 - user_g_cpu_hard_limit;
+    if (empty_group_cpu_share > 0 && empty_group_cpu_share < 100 && 
!contains_empty_group) {
+        _empty_group_entity->update_empty_cpu_share(empty_group_cpu_share);
+        _enqueue_task_group(_empty_group_entity);
+    } else if ((empty_group_cpu_share == 0 || empty_group_cpu_share == 100) &&
+               contains_empty_group) {
+        _dequeue_task_group(_empty_group_entity);

Review Comment:
   the op is dangerous,do not set the empty cpu share, so `empty_group_entity` 
the `cpu_share` is undefine



##########
be/src/vec/exec/scan/scan_task_queue.cpp:
##########
@@ -132,6 +205,31 @@ void ScanTaskTaskGroupQueue::update_tg_cpu_share(const 
taskgroup::TaskGroupInfo&
     }
 }
 
+void ScanTaskTaskGroupQueue::reset_empty_group_entity() {
+    int user_g_cpu_hard_limit = 0;
+    bool contains_empty_group = false;
+    for (auto* entity : _group_entities) {
+        if (!entity->is_empty_group_entity()) {
+            user_g_cpu_hard_limit += entity->cpu_share();
+        } else {
+            contains_empty_group = true;
+        }
+    }
+
+    // 0 <= user_g_cpu_hard_limit <= 100, bound by FE
+    // user_g_cpu_hard_limit = 0 means no group exists
+    int empty_group_cpu_share = 100 - user_g_cpu_hard_limit;
+    if (empty_group_cpu_share > 0 && empty_group_cpu_share < 100 && 
!contains_empty_group) {
+        _empty_group_entity->update_empty_cpu_share(empty_group_cpu_share);
+        _enqueue_task_group(_empty_group_entity);
+    } else if ((empty_group_cpu_share == 0 || empty_group_cpu_share == 100) &&
+               contains_empty_group) {
+        _dequeue_task_group(_empty_group_entity);

Review Comment:
   the op is dangerous,do not set the empty cpu share, so `empty_group_entity` 
the `cpu_share` is undefine



##########
be/src/vec/exec/scan/scan_task_queue.cpp:
##########
@@ -78,9 +141,16 @@ bool ScanTaskTaskGroupQueue::take(ScanTask* scan_task) {
             }
         }
     }
+    if (entity->is_empty_group_entity()) {
+        *scan_task = *_empty_scan_task;
+        return true;
+    }
     DCHECK(entity->task_size() > 0);
     if (entity->task_size() == 1) {
         _dequeue_task_group(entity);
+        if (_enable_cpu_hard_limit) {

Review Comment:
   better impl the code in `dequeue` and `enqueue`



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to