kaka11chen commented on code in PR #49671: URL: https://github.com/apache/doris/pull/49671#discussion_r2048807811
########## be/src/vec/exec/executor/time_sharing/time_sharing_task_executor.h: ########## @@ -0,0 +1,183 @@ +// 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 <atomic> +#include <chrono> +#include <condition_variable> +#include <memory> +#include <mutex> +#include <optional> +#include <queue> +#include <thread> +#include <unordered_map> +#include <unordered_set> +#include <vector> + +#include "bvar/latency_recorder.h" +#include "util/threadpool.h" +#include "vec/exec/executor/listenable_future.h" +#include "vec/exec/executor/task_executor.h" +#include "vec/exec/executor/ticker.h" +#include "vec/exec/executor/time_sharing/multilevel_split_queue.h" +#include "vec/exec/executor/time_sharing/prioritized_split_runner.h" + +namespace doris { +namespace vectorized { + +/** + * ThreadSafe + */ +class TimeSharingTaskExecutor : public TaskExecutor { + ENABLE_FACTORY_CREATOR(TimeSharingTaskExecutor); + +public: + struct ThreadConfig { + std::string thread_name; + int max_thread_num; + int min_thread_num; + int max_queue_size = 0; + std::weak_ptr<CgroupCpuCtl> cgroup_cpu_ctl; + }; + + TimeSharingTaskExecutor(ThreadConfig config, int min_concurrency, + int guaranteed_concurrency_per_task, int max_concurrency_per_task, + std::shared_ptr<Ticker> ticker, + std::chrono::milliseconds stuck_split_warning_threshold = + std::chrono::milliseconds(60000), + std::shared_ptr<MultilevelSplitQueue> split_queue = nullptr); + + ~TimeSharingTaskExecutor() override; + + Status init() override; + + Status start() override; + void stop() override; + + Result<std::shared_ptr<TaskHandle>> create_task( + const TaskId& task_id, std::function<double()> utilization_supplier, + int initial_split_concurrency, + std::chrono::nanoseconds split_concurrency_adjust_frequency, + std::optional<int> max_concurrency_per_task) override; + + Status add_task(const TaskId& task_id, std::shared_ptr<TaskHandle> task_handle) override; Review Comment: `create_task()` is used to create tasks and add them. `add_task()` is not used yet, but may be used in the future to transfer existing tasks from another scheduler. Considering the cgroup multi-tenancy situation. -- 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