Skip to content

Commit cab14c2

Browse files
hzxa21mergify[bot]
andauthored
chore(metrics): improve compaction group label and grafana dashboard (#4258)
* chore(metrics): improve compaction group label and grafana dashboard * fix Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 3dbf022 commit cab14c2

File tree

8 files changed

+219
-195
lines changed

8 files changed

+219
-195
lines changed

Cargo.lock

Lines changed: 92 additions & 80 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

grafana/risingwave-dashboard.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

grafana/risingwave-dashboard.py

Lines changed: 101 additions & 104 deletions
Large diffs are not rendered by default.

src/meta/src/hummock/metrics_utils.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ use std::sync::atomic::Ordering;
1616
use std::time::{SystemTime, UNIX_EPOCH};
1717

1818
use itertools::enumerate;
19+
use num_traits::FromPrimitive;
1920
use prost::Message;
2021
use risingwave_hummock_sdk::compaction_group::hummock_version_ext::HummockVersionExt;
22+
use risingwave_hummock_sdk::compaction_group::StaticCompactionGroupId;
2123
use risingwave_hummock_sdk::CompactionGroupId;
2224
use risingwave_pb::hummock::HummockVersion;
2325

@@ -46,7 +48,11 @@ pub fn trigger_sst_stat(
4648
for (idx, level_handler) in enumerate(compact_status.level_handlers.iter()) {
4749
let sst_num = level_sst_cnt(idx);
4850
let compact_cnt = level_handler.get_pending_file_count();
49-
let level_label = format!("cg{}_level{}", compaction_group_id, idx);
51+
let level_label = format!(
52+
"{}_{}",
53+
idx,
54+
StaticCompactionGroupId::from_u64(compaction_group_id).unwrap(),
55+
);
5056
metrics
5157
.level_sst_num
5258
.with_label_values(&[&level_label])

src/storage/hummock_sdk/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ hex = "0.4"
99
itertools = "0.10"
1010
log = "0.4"
1111
madsim = "=0.2.0-alpha.5"
12+
num-derive = "0.3"
13+
num-traits = "0.2"
1214
prost = "0.10"
1315
risingwave_common = { path = "../../common" }
1416
risingwave_pb = { path = "../../prost" }

src/storage/hummock_sdk/src/compaction_group/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@
1414

1515
pub mod hummock_version_ext;
1616

17+
use std::fmt::Display;
18+
1719
use crate::CompactionGroupId;
1820

1921
pub type StateTableId = u32;
2022

2123
/// A compaction task's `StaticCompactionGroupId` indicates the compaction group that all its input
2224
/// SSTs belong to.
25+
#[derive(FromPrimitive)]
2326
pub enum StaticCompactionGroupId {
2427
/// All shared buffer local compaction task goes to here. Meta service will never see this
2528
/// value. Note that currently we've restricted the compaction task's input by `via
@@ -36,3 +39,13 @@ impl From<StaticCompactionGroupId> for CompactionGroupId {
3639
cg as CompactionGroupId
3740
}
3841
}
42+
43+
impl Display for StaticCompactionGroupId {
44+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
45+
match self {
46+
StaticCompactionGroupId::SharedBuffer => write!(f, "SharedBufferGroup"),
47+
StaticCompactionGroupId::StateDefault => write!(f, "StateGroup"),
48+
StaticCompactionGroupId::MaterializedView => write!(f, "MVGroup"),
49+
}
50+
}
51+
}

src/storage/hummock_sdk/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
mod version_cmp;
1818

19+
#[macro_use]
20+
extern crate num_derive;
21+
1922
use risingwave_pb::hummock::SstableInfo;
2023
pub use version_cmp::*;
2124
pub mod compact;

src/storage/src/monitor/state_store_metrics.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ macro_rules! for_all_metrics {
5757
write_build_l0_bytes: GenericCounter<AtomicU64>,
5858

5959
iter_merge_sstable_counts: HistogramVec,
60-
iter_merge_seek_duration: Histogram,
6160

6261
sst_store_block_request_counts: GenericCounterVec<AtomicU64>,
6362

@@ -274,13 +273,6 @@ impl StateStoreMetrics {
274273
let iter_merge_sstable_counts =
275274
register_histogram_vec_with_registry!(opts, &["type"], registry).unwrap();
276275

277-
let opts = histogram_opts!(
278-
"state_store_iter_merge_seek_duration",
279-
"Seek() time conducted by MergeIterators",
280-
exponential_buckets(1.0, 2.0, 17).unwrap() // max 65536 times
281-
);
282-
let iter_merge_seek_duration = register_histogram_with_registry!(opts, registry).unwrap();
283-
284276
// ----- sst store -----
285277
let sst_store_block_request_counts = register_int_counter_vec_with_registry!(
286278
"state_store_sst_store_block_request_counts",
@@ -410,7 +402,6 @@ impl StateStoreMetrics {
410402
write_build_l0_sst_duration,
411403
write_build_l0_bytes,
412404
iter_merge_sstable_counts,
413-
iter_merge_seek_duration,
414405
sst_store_block_request_counts,
415406
shared_buffer_to_l0_duration,
416407
shared_buffer_to_sstable_size,

0 commit comments

Comments
 (0)