[feature](profile) sort pipelineX task by total time #34053
This commit is contained in:
@ -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<TaskExecutionContext> context) {
|
||||
_task_execution_context_inited = true;
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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.
|
||||
|
||||
Reference in New Issue
Block a user