Skip to content

Commit

Permalink
[perf] change async run stragety
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunelFeng committed Aug 19, 2023
1 parent f3880ed commit 6717f7d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions src/GraphCtrl/GraphPipeline/GPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,14 @@ CStatus GPipeline::process(CSize runTimes) {

std::future<CStatus> GPipeline::asyncRun() {
/**
* 1. 确定是否已经初始化
* 2. 确定线程资源是ok的(理论上,初始化后,就一定会有值)
* 3. 异步的执行 run() 方法,并且返回执行结果的 future 信息
* 1. 确认当前pipeline已经初始化完毕
* 2. 异步的执行 run() 方法,并且返回执行结果的 future 信息
*/
CGRAPH_ASSERT_INIT_THROW_ERROR(true)

auto tp = schedule_.getThreadPool();
CGRAPH_ASSERT_NOT_NULL_THROW_ERROR(tp)

return tp->commitWithPriority([this] {
return std::async(std::launch::async, [this] {
return run();
}, CGRAPH_DEFAULT_PRIORITY);
});
}


Expand Down Expand Up @@ -248,6 +244,7 @@ CStatus GPipeline::makeSerial() {
config.secondary_thread_size_ = 0;
config.max_thread_size_ = 0;
config.monitor_enable_ = false;
config.batch_task_enable_ = false;
schedule_.config_ = config;
CGRAPH_FUNCTION_END
}
Expand Down
2 changes: 1 addition & 1 deletion src/UtilsCtrl/ThreadPool/UThreadPoolDefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static const int CGRAPH_MAX_LOCAL_BATCH_SIZE = 2;
static const int CGRAPH_MAX_POOL_BATCH_SIZE = 2; // 批量执行通用任务最大值
static const int CGRAPH_MAX_STEAL_BATCH_SIZE = 2; // 批量盗取任务最大值
static const int CGRAPH_SECONDARY_THREAD_TTL = 10; // 辅助线程ttl,单位为s
static const bool CGRAPH_MONITOR_ENABLE = false; // 是否开启监控程序(如果不开启,辅助线程策略将失效)
static const bool CGRAPH_MONITOR_ENABLE = false; // 是否开启监控程序
static const int CGRAPH_MONITOR_SPAN = 5; // 监控线程执行间隔,单位为s
static const CMSec CGRAPH_QUEUE_EMPTY_INTERVAL = 50; // 队列为空时,等待的时间。仅针对辅助线程,单位为ms
static const bool CGRAPH_BIND_CPU_ENABLE = false; // 是否开启绑定cpu模式(仅针对主线程)
Expand Down

0 comments on commit 6717f7d

Please sign in to comment.