Skip to content

Commit

Permalink
Storages: add metrics of read thread (#9412) (#9421)
Browse files Browse the repository at this point in the history
ref #9417

Signed-off-by: ti-chi-bot <[email protected]>

Co-authored-by: jinhelin <[email protected]>
Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Sep 20, 2024
1 parent 9566029 commit 6b739dc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion dbms/src/Common/TiFlashMetrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,8 @@ namespace DB
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)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ bool SegmentReadTaskScheduler::isStop() const

std::tuple<UInt64, UInt64, UInt64> SegmentReadTaskScheduler::scheduleOneRound()
{
Stopwatch sw;
UInt64 erased_pool_count = 0;
UInt64 sched_null_count = 0;
UInt64 sched_succ_count = 0;
Expand Down Expand Up @@ -276,6 +277,7 @@ std::tuple<UInt64, UInt64, UInt64> 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);
}

Expand Down
1 change: 1 addition & 0 deletions dbms/src/Storages/DeltaMerge/SegmentReadTaskPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ void SegmentReadTaskPool::finishSegment(const SegmentPtr & seg)
if (pool_finished)
{
q.finish();
LOG_INFO(log, "pool_id={} finished", pool_id);
}
}

Expand Down
6 changes: 3 additions & 3 deletions dbms/src/Storages/DeltaMerge/SegmentReadTaskPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ class SegmentReadTaskPool : private boost::noncopyable
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={} table_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,
physical_table_id,
Expand All @@ -173,7 +173,7 @@ class SegmentReadTaskPool : private boost::noncopyable
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,
Expand Down

0 comments on commit 6b739dc

Please sign in to comment.