Skip to content

Commit

Permalink
Add metric to record end to end time to pre-handle snapshot (#3978)
Browse files Browse the repository at this point in the history
close #3759
  • Loading branch information
CalvinNeo authored Mar 22, 2022
1 parent 288aa19 commit 2b71569
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 1 deletion.
1 change: 1 addition & 0 deletions dbms/src/Common/TiFlashMetrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ namespace DB
Histogram, /* these command usually cost servel seconds, increase the start bucket to 50ms */ \
F(type_ingest_sst, {{"type", "ingest_sst"}}, ExpBuckets{0.05, 2, 10}), \
F(type_apply_snapshot_predecode, {{"type", "snapshot_predecode"}}, ExpBuckets{0.05, 2, 10}), \
F(type_apply_snapshot_predecode_sst2dt, {{"type", "snapshot_predecode_sst2dt"}}, ExpBuckets{0.05, 2, 10}), \
F(type_apply_snapshot_flush, {{"type", "snapshot_flush"}}, ExpBuckets{0.05, 2, 10})) \
M(tiflash_raft_process_keys, "Total number of keys processed in some types of Raft commands", Counter, \
F(type_apply_snapshot, {"type", "apply_snapshot"}), F(type_ingest_sst, {"type", "ingest_sst"})) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void SSTFilesToDTFilesOutputStream::writeSuffix()
const auto process_keys = child->getProcessKeys();
if (job_type == FileConvertJobType::ApplySnapshot)
{
GET_METRIC(tiflash_raft_command_duration_seconds, type_apply_snapshot_predecode).Observe(watch.elapsedSeconds());
GET_METRIC(tiflash_raft_command_duration_seconds, type_apply_snapshot_predecode_sst2dt).Observe(watch.elapsedSeconds());
// Note that number of keys in different cf will be aggregated into one metrics
GET_METRIC(tiflash_raft_process_keys, type_apply_snapshot).Increment(process_keys.total());
}
Expand Down
3 changes: 3 additions & 0 deletions dbms/src/Storages/Transaction/ApplySnapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ std::vector<UInt64> KVStore::preHandleSSTsToDTFiles(
// Use failpoint to change the expected_block_size for some test cases
fiu_do_on(FailPoints::force_set_sst_to_dtfile_block_size, { expected_block_size = 3; });

Stopwatch watch;
SCOPE_EXIT({ GET_METRIC(tiflash_raft_command_duration_seconds, type_apply_snapshot_predecode).Observe(watch.elapsedSeconds()); });

PageIds ids;
while (true)
{
Expand Down
66 changes: 66 additions & 0 deletions metrics/grafana/tiflash_summary.json
Original file line number Diff line number Diff line change
Expand Up @@ -6407,6 +6407,72 @@
"yBucketNumber": null,
"yBucketSize": null
},
{
"cards": {
"cardPadding": null,
"cardRound": null
},
"color": {
"cardColor": "#b4ff00",
"colorScale": "sqrt",
"colorScheme": "interpolateSpectral",
"exponent": 0.5,
"min": 0,
"mode": "spectrum"
},
"dataFormat": "tsbuckets",
"datasource": "${DS_TEST-CLUSTER}",
"description": "Duration of SST to DT in pre-decode when applying region snapshot",
"gridPos": {
"h": 7,
"w": 12,
"x": 12,
"y": 34
},
"heatmap": {},
"hideZeroBuckets": true,
"highlightCards": true,
"id": 100,
"legend": {
"show": true
},
"links": [],
"reverseYBuckets": false,
"targets": [
{
"expr": "sum(delta(tiflash_raft_command_duration_seconds_bucket{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\", instance=~\"$instance\", type=\"snapshot_predecode_sst2dt\"}[1m])) by (le)",
"format": "heatmap",
"intervalFactor": 2,
"legendFormat": "{{le}}",
"refId": "B"
}
],
"timeFrom": null,
"timeShift": null,
"title": "Snapshot Predecode SST to DT Duration",
"tooltip": {
"show": true,
"showHistogram": true
},
"type": "heatmap",
"xAxis": {
"show": true
},
"xBucketNumber": null,
"xBucketSize": null,
"yAxis": {
"decimals": 0,
"format": "s",
"logBase": 1,
"max": null,
"min": null,
"show": true,
"splitFactor": null
},
"yBucketBound": "upper",
"yBucketNumber": null,
"yBucketSize": null
},
{
"cards": {
"cardPadding": null,
Expand Down

0 comments on commit 2b71569

Please sign in to comment.