You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/08/07 16:30:29 UTC

[GitHub] [doris] morningman opened a new pull request, #11582: [feature-wip](new-scan) add scanner scheduling framework

morningman opened a new pull request, #11582:
URL: https://github.com/apache/doris/pull/11582

   # Proposed changes
   
   Issue Number: close #xxx
   
   ## Problem summary
   
   Describe your changes.
   
   ## Checklist(Required)
   
   1. Does it affect the original behavior: 
       - [ ] Yes
       - [ ] No
       - [ ] I don't know
   2. Has unit tests been added:
       - [ ] Yes
       - [ ] No
       - [ ] No Need
   3. Has document been added or modified:
       - [ ] Yes
       - [ ] No
       - [ ] No Need
   4. Does it need to update dependencies:
       - [ ] Yes
       - [ ] No
   5. Are there any changes that cannot be rolled back:
       - [ ] Yes (If Yes, please explain WHY)
       - [ ] No
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
   
   


-- 
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-unsubscribe@doris.apache.org

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


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


[GitHub] [doris] Jibing-Li commented on a diff in pull request #11582: [feature-wip](new-scan) add scanner scheduling framework

Posted by GitBox <gi...@apache.org>.
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-unsubscribe@doris.apache.org

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


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


[GitHub] [doris] yiguolei merged pull request #11582: [feature-wip](new-scan) add scanner scheduling framework

Posted by GitBox <gi...@apache.org>.
yiguolei merged PR #11582:
URL: https://github.com/apache/doris/pull/11582


-- 
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-unsubscribe@doris.apache.org

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


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


[GitHub] [doris] Jibing-Li commented on a diff in pull request #11582: [feature-wip](new-scan) add scanner scheduling framework

Posted by GitBox <gi...@apache.org>.
Jibing-Li commented on code in PR #11582:
URL: https://github.com/apache/doris/pull/11582#discussion_r942060667


##########
be/src/vec/exec/scan/scanner_context.cpp:
##########
@@ -0,0 +1,123 @@
+// 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.
+
+#include "scanner_context.h"
+
+#include "common/config.h"
+#include "runtime/runtime_state.h"
+#include "util/threadpool.h"
+#include "vec/core/block.h"
+
+namespace doris {
+
+Status ScannerContext::init() {
+    // 1. Calculate how many blocks need to be preallocated.
+    // The calculation logic is as follows:
+    //  1. Assuming that at most M rows can be scanned in one scan(config::doris_scanner_row_num),
+    //     then figure out how many blocks are required for one scan(block_per_scanner).
+    //  2. The maximum number of concurrency * the blocks required for one scan,
+    //     that is, the number of blocks that need to be pre-allocated
+    auto doris_scanner_row_num =
+            limit == -1 ? config::doris_scanner_row_num
+                        : std::min(static_cast<int64_t>(config::doris_scanner_row_num), limit);
+    int real_block_size =
+            limit == -1 ? block_size : std::min(static_cast<int64_t>(state->batch_size()), limit);

Review Comment:
   the variable `block_size` in ` limit == -1 ? block_size ` is not initialized, should we use `state->batch_size()` instead?



-- 
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-unsubscribe@doris.apache.org

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


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


[GitHub] [doris] github-actions[bot] commented on pull request #11582: [feature-wip](new-scan) add scanner scheduling framework

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #11582:
URL: https://github.com/apache/doris/pull/11582#issuecomment-1220369468

   PR approved by anyone and no changes requested.


-- 
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-unsubscribe@doris.apache.org

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


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