Jibing-Li commented on code in PR #11582:
URL: https://github.com/apache/doris/pull/11582#discussion_r940998214


##########
be/src/vec/exec/scan/scanner_scheduler.h:
##########
@@ -0,0 +1,82 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include "common/status.h"
+#include "util/blocking_queue.hpp"
+#include "vec/exec/scan/scanner_context.h"
+
+namespace doris {
+
+// Responsible for the scheduling and execution of all Scanners of a BE node.
+// ScannerScheduler has two types of thread pools:
+// 1. Scheduling thread pool
+//     Responsible for Scanner scheduling.
+//     A set of Scanners for a query will be encapsulated into a ScannerContext
+//     and submitted to the ScannerScheduler's scheduling queue.
+//     There are multiple scheduling queues in ScannerScheduler, and each 
scheduling queue
+//     is handled by a scheduling thread.
+//     The scheduling thread is scheduled in granularity of ScannerContext,
+//     that is, a group of Scanners in a ScannerContext are scheduled at a 
time.
+//
+//2. Execution thread pool
+//     The scheduling thread will submit the Scanners selected from the 
ScannerContext
+//     to the execution thread pool to do the actual scan task.
+//     Each Scanner will act as a producer, read a group of blocks and put 
them into
+//     the corresponding block queue.
+//     The corresponding ScanNode will act as a consumer to consume blocks 
from the block queue.
+class Env;
+class ScannerScheduler {
+public:
+    ScannerScheduler();
+    ~ScannerScheduler();
+
+    Status init(ExecEnv* env);
+
+    Status submit(ScannerContext* ctx);
+
+private:
+    // scheduling thread function
+    void _schedule_thread(int queue_id);
+    // schedule scanners in a certain ScannerContext
+    void _schedule_scanners(ScannerContext* ctx);
+    // execution thread function
+    void _scanner_scan(ScannerContext* ctx, VScanner* scanner);
+
+private:
+    // scheduling queue number.
+    // TODO: make it configurable.
+    static const int QUEUE_NUM = 4;
+    // the ScannerContext will be submitted to the scheduling queue roundrobin.
+    // _queue_idx pointer to the current queue.
+    std::atomic_int _queue_idx = {0};
+    BlockingQueue<ScannerContext*>** _scheduling_queues;

Review Comment:
   Why do we need multiple scheduling queues?



-- 
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