This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
commit d7b77930f80ace8bb648311deb803d3938190757 Author: Mryange <[email protected]> AuthorDate: Wed Apr 24 18:12:03 2024 +0800 [feature](profile) sort pipelineX task by total time #34053 --- be/src/runtime/runtime_state.h | 13 ++++++++++++- be/src/util/runtime_profile.cpp | 12 ++++++++++++ be/src/util/runtime_profile.h | 2 ++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/be/src/runtime/runtime_state.h b/be/src/runtime/runtime_state.h index 6d5a6451fb4..64dd661cac0 100644 --- a/be/src/runtime/runtime_state.h +++ b/be/src/runtime/runtime_state.h @@ -574,7 +574,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<TaskExecutionContext> context) { _task_execution_context_inited = true; diff --git a/be/src/util/runtime_profile.cpp b/be/src/util/runtime_profile.cpp index 782009d4438..ca94329bc85 100644 --- a/be/src/util/runtime_profile.cpp +++ b/be/src/util/runtime_profile.cpp @@ -25,6 +25,7 @@ #include <rapidjson/stringbuffer.h> #include <rapidjson/writer.h> +#include <algorithm> #include <iomanip> #include <iostream> @@ -716,4 +717,15 @@ void RuntimeProfile::print_child_counters(const std::string& prefix, } } +void RuntimeProfile::sort_children_by_total_time() { + std::lock_guard<std::mutex> l(_children_lock); + auto cmp = [](const std::pair<RuntimeProfile*, bool>& L, + const std::pair<RuntimeProfile*, bool>& 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 c1756f6c63e..5360a0e991c 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. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
