Skip to content

add: max_executor_thread_num #370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/libmodelbox/base/include/modelbox/base/executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class Executor {

virtual ~Executor();

void SetThreadCount(int thread_count);

template <typename func, typename... ts>
auto Run(func &&fun, int32_t priority, ts &&...params)
-> std::future<typename std::result_of<func(ts...)>::type> {
Expand Down
4 changes: 4 additions & 0 deletions src/libmodelbox/engine/flowunit_data_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ Executor::Executor(int thread_count) {

Executor::~Executor() { thread_pool_ = nullptr; }

void Executor::SetThreadCount(int thread_count){
thread_pool_->SetThreadSize(thread_count);
}

FlowUnitExecContext::FlowUnitExecContext(
std::shared_ptr<FlowUnitDataContext> data_ctx)
: data_ctx_(std::move(data_ctx)) {}
Expand Down
10 changes: 10 additions & 0 deletions src/libmodelbox/engine/flowunit_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ Status FlowUnitManager::Initialize(
SetDeviceManager(std::move(device_mgr));
Status status;
status = InitFlowUnitFactory(driver);

if (config != nullptr){
max_executor_thread_num = config->GetUint32("graph.max_executor_thread_num", 0);
} else {
max_executor_thread_num = 0;
}

if (status != STATUS_SUCCESS) {
return status;
}
Expand Down Expand Up @@ -407,6 +414,9 @@ std::shared_ptr<FlowUnit> FlowUnitManager::CreateSingleFlowUnit(
return nullptr;
}

MBLOG_INFO << "max_executor_thread_num: " << max_executor_thread_num;
device->GetDeviceExecutor()->SetThreadCount(max_executor_thread_num);

flowunit->SetBindDevice(device);
std::vector<FlowUnitInput> &in_list = flowunit_desc->GetFlowUnitInput();
for (auto &in_item : in_list) {
Expand Down
2 changes: 2 additions & 0 deletions src/libmodelbox/include/modelbox/flowunit.h
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,8 @@ class FlowUnitManager {

std::shared_ptr<DeviceManager> GetDeviceManager();

int max_executor_thread_num;

private:
Status CheckParams(const std::string &unit_name, const std::string &unit_type,
const std::string &unit_device_id);
Expand Down