From 2c10e0c978441b13486fa128e712431704b294fc Mon Sep 17 00:00:00 2001 From: jinhelin Date: Fri, 6 Sep 2024 16:45:06 +0800 Subject: [PATCH] This is an automated cherry-pick of #9412 Signed-off-by: ti-chi-bot --- dbms/src/Common/TiFlashMetrics.h | 3 ++- .../DeltaMerge/ReadThread/SegmentReadTaskScheduler.cpp | 2 ++ dbms/src/Storages/DeltaMerge/SegmentReadTaskPool.cpp | 1 + dbms/src/Storages/DeltaMerge/SegmentReadTaskPool.h | 6 +++--- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/dbms/src/Common/TiFlashMetrics.h b/dbms/src/Common/TiFlashMetrics.h index b7e93bea214..e64798e3f13 100644 --- a/dbms/src/Common/TiFlashMetrics.h +++ b/dbms/src/Common/TiFlashMetrics.h @@ -852,7 +852,8 @@ static_assert(RAFT_REGION_BIG_WRITE_THRES * 4 < RAFT_REGION_BIG_WRITE_MAX, "Inva M(tiflash_read_thread_internal_us, \ "Durations of read thread internal components", \ Histogram, \ - F(type_block_queue_pop_latency, {{"type", "block_queue_pop_latency"}}, ExpBuckets{1, 2, 20})) + F(type_block_queue_pop_latency, {{"type", "block_queue_pop_latency"}}, ExpBuckets{1, 2, 20}), \ + F(type_schedule_one_round, {{"type", "schedule_one_round"}}, ExpBuckets{1, 2, 20})) /// Buckets with boundaries [start * base^0, start * base^1, ..., start * base^(size-1)] diff --git a/dbms/src/Storages/DeltaMerge/ReadThread/SegmentReadTaskScheduler.cpp b/dbms/src/Storages/DeltaMerge/ReadThread/SegmentReadTaskScheduler.cpp index 360d732c1ac..e482a541024 100644 --- a/dbms/src/Storages/DeltaMerge/ReadThread/SegmentReadTaskScheduler.cpp +++ b/dbms/src/Storages/DeltaMerge/ReadThread/SegmentReadTaskScheduler.cpp @@ -233,6 +233,7 @@ bool SegmentReadTaskScheduler::isStop() const std::tuple SegmentReadTaskScheduler::scheduleOneRound() { + Stopwatch sw; UInt64 erased_pool_count = 0; UInt64 sched_null_count = 0; UInt64 sched_succ_count = 0; @@ -265,6 +266,7 @@ std::tuple SegmentReadTaskScheduler::scheduleOneRound() ++sched_succ_count; SegmentReaderPoolManager::instance().addTask(std::move(merged_task)); } + GET_METRIC(tiflash_read_thread_internal_us, type_schedule_one_round).Observe(sw.elapsed() / 1000.0); return std::make_tuple(erased_pool_count, sched_null_count, sched_succ_count); } diff --git a/dbms/src/Storages/DeltaMerge/SegmentReadTaskPool.cpp b/dbms/src/Storages/DeltaMerge/SegmentReadTaskPool.cpp index 711cb5ee335..75ce3760e98 100644 --- a/dbms/src/Storages/DeltaMerge/SegmentReadTaskPool.cpp +++ b/dbms/src/Storages/DeltaMerge/SegmentReadTaskPool.cpp @@ -169,6 +169,7 @@ void SegmentReadTaskPool::finishSegment(const SegmentReadTaskPtr & seg) if (pool_finished) { q.finish(); + LOG_INFO(log, "pool_id={} finished", pool_id); } } diff --git a/dbms/src/Storages/DeltaMerge/SegmentReadTaskPool.h b/dbms/src/Storages/DeltaMerge/SegmentReadTaskPool.h index b9557a99e6a..3109b8b9c48 100644 --- a/dbms/src/Storages/DeltaMerge/SegmentReadTaskPool.h +++ b/dbms/src/Storages/DeltaMerge/SegmentReadTaskPool.h @@ -124,12 +124,12 @@ class SegmentReadTaskPool auto total_count = blk_stat.totalCount(); auto total_bytes = blk_stat.totalBytes(); auto blk_avg_bytes = total_count > 0 ? total_bytes / total_count : 0; - auto approximate_max_pending_block_bytes = blk_avg_bytes * max_queue_size; + auto approx_max_pending_block_bytes = blk_avg_bytes * max_queue_size; auto total_rows = blk_stat.totalRows(); LOG_INFO( log, "Done. pool_id={} pop={} pop_empty={} pop_empty_ratio={} " - "max_queue_size={} blk_avg_bytes={} approximate_max_pending_block_bytes={:.2f}MB " + "max_queue_size={} blk_avg_bytes={} approx_max_pending_block_bytes={:.2f}MB " "total_count={} total_bytes={:.2f}MB total_rows={} avg_block_rows={} avg_rows_bytes={}B", pool_id, pop_times, @@ -137,7 +137,7 @@ class SegmentReadTaskPool pop_empty_ratio, max_queue_size, blk_avg_bytes, - approximate_max_pending_block_bytes / 1024.0 / 1024.0, + approx_max_pending_block_bytes / 1024.0 / 1024.0, total_count, total_bytes / 1024.0 / 1024.0, total_rows,