mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
transfer counters to the query directly
This commit is contained in:
parent
f504cd5fed
commit
c1adbb7aa6
@ -4,6 +4,8 @@
|
||||
#include <Storages/StorageMergeTree.h>
|
||||
#include <Storages/MergeTree/MergeTreeDataMergerMutator.h>
|
||||
#include <Common/ProfileEventsScope.h>
|
||||
#include <Common/ProfileEvents.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
{
|
||||
@ -106,6 +108,19 @@ void MergePlainMergeTreeTask::prepare()
|
||||
std::move(profile_counters_snapshot));
|
||||
};
|
||||
|
||||
transfer_profile_counters_to_initial_query = [this, query_thread_group = CurrentThread::getGroup()] ()
|
||||
{
|
||||
if (query_thread_group)
|
||||
{
|
||||
auto task_thread_group = (*merge_list_entry)->thread_group;
|
||||
auto task_counters_snapshot = task_thread_group->performance_counters.getPartiallyAtomicSnapshot();
|
||||
|
||||
auto & query_counters = query_thread_group->performance_counters;
|
||||
for (ProfileEvents::Event i = ProfileEvents::Event(0); i < ProfileEvents::end(); ++i)
|
||||
query_counters.incrementNoTrace(i, task_counters_snapshot[i]);
|
||||
}
|
||||
};
|
||||
|
||||
merge_task = storage.merger_mutator.mergePartsToTemporaryPart(
|
||||
future_part,
|
||||
metadata_snapshot,
|
||||
@ -133,6 +148,7 @@ void MergePlainMergeTreeTask::finish()
|
||||
|
||||
write_part_log({});
|
||||
storage.incrementMergedPartsProfileEvent(new_part->getType());
|
||||
transfer_profile_counters_to_initial_query();
|
||||
}
|
||||
|
||||
ContextMutablePtr MergePlainMergeTreeTask::createTaskContext() const
|
||||
|
@ -80,6 +80,7 @@ private:
|
||||
UInt64 priority{0};
|
||||
|
||||
std::function<void(const ExecutionStatus &)> write_part_log;
|
||||
std::function<void()> transfer_profile_counters_to_initial_query;
|
||||
IExecutableTask::TaskResultCallback task_result_callback;
|
||||
MergeTaskPtr merge_task{nullptr};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user