Skip to content

Commit fe58780

Browse files
authored
KVStore: More metrics for Prehandling (pingcap#9131) (pingcap#213)
Signed-off-by: CalvinNeo <[email protected]>
1 parent ecb158e commit fe58780

File tree

3 files changed

+2208
-1
lines changed

3 files changed

+2208
-1
lines changed

Diff for: dbms/src/Common/TiFlashMetrics.h

+5
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,10 @@ namespace DB
424424
F(type_total, {{"type", "total"}}, ExpBucketsWithRange{0.2, 4, 300}), \
425425
F(type_queue_stage, {{"type", "queue_stage"}}, ExpBucketsWithRange{0.2, 4, 300}), \
426426
F(type_phase1_total, {{"type", "phase1_total"}}, ExpBucketsWithRange{0.2, 4, 300})) \
427+
M(tiflash_raft_command_throughput, \
428+
"", \
429+
Histogram, \
430+
F(type_prehandle_snapshot, {{"type", "prehandle_snapshot"}}, ExpBuckets{128, 2, 11})) \
427431
M(tiflash_raft_command_duration_seconds, \
428432
"Bucketed histogram of some raft command: apply snapshot and ingest SST", \
429433
Histogram, /* these command usually cost several seconds, increase the start bucket to 50ms */ \
@@ -484,6 +488,7 @@ namespace DB
484488
F(type_flush_log_gap, {{"type", "flush_log_gap"}}), \
485489
F(type_flush_size, {{"type", "flush_size"}}), \
486490
F(type_flush_rowcount, {{"type", "flush_rowcount"}}), \
491+
F(type_prehandle, {{"type", "prehandle"}}), \
487492
F(type_flush_eager_gc, {{"type", "flush_eager_gc"}})) \
488493
M(tiflash_raft_raft_frequent_events_count, \
489494
"Raft frequent event counter", \

Diff for: dbms/src/Storages/KVStore/MultiRaft/PrehandleSnapshot.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ static inline std::tuple<ReadFromStreamResult, PrehandleResult> executeTransform
138138
trace.releaseSubtaskResources(region_id, split_id);
139139
CurrentMetrics::sub(CurrentMetrics::RaftNumPrehandlingSubTasks);
140140
});
141+
Stopwatch sw;
141142
LOG_INFO(
142143
log,
143144
"Add prehandle task split_id={} limit={}",
@@ -198,6 +199,10 @@ static inline std::tuple<ReadFromStreamResult, PrehandleResult> executeTransform
198199
stream->cancel();
199200
res = ReadFromStreamResult{.error = ReadFromStreamError::Aborted, .extra_msg = "", .region = new_region};
200201
}
202+
auto keys_per_second = (sst_stream->getProcessKeys().write_cf + sst_stream->getProcessKeys().lock_cf
203+
+ sst_stream->getProcessKeys().write_cf)
204+
* 1.0 / sw.elapsedSeconds();
205+
GET_METRIC(tiflash_raft_command_throughput, type_prehandle_snapshot).Observe(keys_per_second);
201206
return std::make_pair(
202207
std::move(res),
203208
PrehandleResult{
@@ -252,6 +257,7 @@ PrehandleResult KVStore::preHandleSnapshotToFiles(
252257
std::optional<uint64_t> deadline_index,
253258
TMTContext & tmt)
254259
{
260+
GET_METRIC(tiflash_raft_raft_events_count, type_prehandle).Increment();
255261
new_region->beforePrehandleSnapshot(new_region->id(), deadline_index);
256262

257263
ongoing_prehandle_task_count.fetch_add(1);

0 commit comments

Comments
 (0)