diff --git a/be/src/runtime/runtime_state.h b/be/src/runtime/runtime_state.h index 644db3e32e..38ef5ff245 100644 --- a/be/src/runtime/runtime_state.h +++ b/be/src/runtime/runtime_state.h @@ -569,7 +569,18 @@ public: void resize_op_id_to_local_state(int operator_size); - auto& pipeline_id_to_profile() { return _pipeline_id_to_profile; } + auto& pipeline_id_to_profile() { + for (auto& pipeline_profile : _pipeline_id_to_profile) { + // pipeline 0 + // pipeline task 0 + // pipeline task 1 + // pipleine task 2 + // ....... + // sort by pipeline task total time + pipeline_profile->sort_children_by_total_time(); + } + return _pipeline_id_to_profile; + } void set_task_execution_context(std::shared_ptr context) { _task_execution_context_inited = true; diff --git a/be/src/util/runtime_profile.cpp b/be/src/util/runtime_profile.cpp index 782009d443..ca94329bc8 100644 --- a/be/src/util/runtime_profile.cpp +++ b/be/src/util/runtime_profile.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -716,4 +717,15 @@ void RuntimeProfile::print_child_counters(const std::string& prefix, } } +void RuntimeProfile::sort_children_by_total_time() { + std::lock_guard l(_children_lock); + auto cmp = [](const std::pair& L, + const std::pair& R) { + const RuntimeProfile* L_profile = L.first; + const RuntimeProfile* R_profile = R.first; + return L_profile->_counter_total_time.value() > R_profile->_counter_total_time.value(); + }; + std::sort(_children.begin(), _children.end(), cmp); +} + } // namespace doris diff --git a/be/src/util/runtime_profile.h b/be/src/util/runtime_profile.h index c1756f6c63..5360a0e991 100644 --- a/be/src/util/runtime_profile.h +++ b/be/src/util/runtime_profile.h @@ -301,6 +301,8 @@ public: std::sort(_children.begin(), _children.end(), cmp); } + void sort_children_by_total_time(); + // Merges the src profile into this one, combining counters that have an identical // path. Info strings from profiles are not merged. 'src' would be a const if it // weren't for locking.