Skip to content

Commit

Permalink
[perf] para beforeRun(), in perf-test-04, 12.2s -> 11.2s
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunelFeng committed Aug 12, 2024
1 parent e8631d9 commit 88bb058
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ CStatus GDynamicEngine::setup(const GSortedGElementPtrSet& elements) {

CStatus GDynamicEngine::run() {
CGRAPH_FUNCTION_BEGIN
cur_status_.reset();

switch (dag_type_) {
case internal::GEngineDagType::COMMON: {
beforeRun();
asyncRunAndWait();
commonRunAll();
break;
}
case internal::GEngineDagType::ALL_SERIAL: {
Expand Down Expand Up @@ -67,12 +67,13 @@ CStatus GDynamicEngine::afterRunCheck() {
}


CVoid GDynamicEngine::asyncRunAndWait() {
CVoid GDynamicEngine::commonRunAll() {
/**
* 1. 执行没有任何依赖的element
* 2. 在element执行完成之后,进行裂变,直到所有的element执行完成
* 3. 等待异步执行结束
*/
finished_end_size_ = 0;
for (const auto& element : front_element_arr_) {
process(element, element == front_element_arr_.back());
}
Expand All @@ -81,15 +82,6 @@ CVoid GDynamicEngine::asyncRunAndWait() {
}


CVoid GDynamicEngine::beforeRun() {
finished_end_size_ = 0;
cur_status_.reset();
for (GElementPtr element : total_element_arr_) {
element->beforeRun();
}
}


CVoid GDynamicEngine::mark(const GSortedGElementPtrSet& elements) {
total_element_arr_.clear();
front_element_arr_.clear();
Expand Down Expand Up @@ -131,6 +123,7 @@ CVoid GDynamicEngine::process(GElementPtr element, CBool affinity) {
}

const auto& exec = [this, element] {
element->beforeRun();
const CStatus& curStatus = element->fatProcessor(CFunctionType::RUN);
if (unlikely(curStatus.isErr())) {
// 当且仅当整体状正常,且当前状态异常的时候,进入赋值逻辑。确保不重复赋值
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,7 @@ class GDynamicEngine : public GEngine {
* @param
* @return
*/
CVoid asyncRunAndWait();

/**
* 动态图运行前重置
* @param
* @return
*/
CVoid beforeRun();
CVoid commonRunAll();

/**
* element 运行element
Expand Down

0 comments on commit 88bb058

Please sign in to comment.