diff --git a/be/src/vec/exec/vsort_node.cpp b/be/src/vec/exec/vsort_node.cpp index a4501e82f3..45ef327dd3 100644 --- a/be/src/vec/exec/vsort_node.cpp +++ b/be/src/vec/exec/vsort_node.cpp @@ -120,6 +120,9 @@ Status VSortNode::prepare(RuntimeState* state) { ADD_CHILD_COUNTER(runtime_profile(), "SortBlocks", TUnit::BYTES, "MemoryUsage"); RETURN_IF_ERROR(_vsort_exec_exprs.prepare(state, child(0)->row_desc(), _row_descriptor)); + _child_get_next_timer = ADD_TIMER(runtime_profile(), "ChildGetResultTime"); + _get_next_timer = ADD_TIMER(runtime_profile(), "GetResultTime"); + _sink_timer = ADD_TIMER(runtime_profile(), "PartialSortTotalTime"); return Status::OK(); } @@ -173,13 +176,20 @@ Status VSortNode::open(RuntimeState* state) { bool eos = false; std::unique_ptr upstream_block = Block::create_unique(); do { - RETURN_IF_ERROR(child(0)->get_next_after_projects( - state, upstream_block.get(), &eos, - std::bind((Status(ExecNode::*)(RuntimeState*, vectorized::Block*, bool*)) & - ExecNode::get_next, - _children[0], std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3))); - RETURN_IF_ERROR_OR_CATCH_EXCEPTION(sink(state, upstream_block.get(), eos)); + { + SCOPED_TIMER(_child_get_next_timer); + RETURN_IF_ERROR(child(0)->get_next_after_projects( + state, upstream_block.get(), &eos, + std::bind((Status(ExecNode::*)(RuntimeState*, vectorized::Block*, bool*)) & + ExecNode::get_next, + _children[0], std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3))); + } + { + SCOPED_TIMER(_sink_timer); + RETURN_IF_ERROR_OR_CATCH_EXCEPTION(sink(state, upstream_block.get(), eos)); + } + } while (!eos); child(0)->close(state); @@ -191,6 +201,7 @@ Status VSortNode::open(RuntimeState* state) { } Status VSortNode::pull(doris::RuntimeState* state, vectorized::Block* output_block, bool* eos) { + SCOPED_TIMER(_get_next_timer); RETURN_IF_ERROR_OR_CATCH_EXCEPTION(_sorter->get_next(state, output_block, eos)); reached_limit(output_block, eos); if (*eos) { diff --git a/be/src/vec/exec/vsort_node.h b/be/src/vec/exec/vsort_node.h index 7798493102..37c781bde2 100644 --- a/be/src/vec/exec/vsort_node.h +++ b/be/src/vec/exec/vsort_node.h @@ -97,6 +97,10 @@ private: std::unique_ptr _sorter; + RuntimeProfile::Counter* _child_get_next_timer = nullptr; + RuntimeProfile::Counter* _sink_timer = nullptr; + RuntimeProfile::Counter* _get_next_timer = nullptr; + static constexpr size_t ACCUMULATED_PARTIAL_SORT_THRESHOLD = 256; };