Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rocksdb] add metric for pending compaction bytes and memtable flushes #19112

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions crates/typed-store/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pub struct ColumnFamilyMetrics {
pub rocksdb_estimate_table_readers_mem: IntGaugeVec,
pub rocksdb_mem_table_flush_pending: IntGaugeVec,
pub rocksdb_compaction_pending: IntGaugeVec,
pub rocksdb_estimate_pending_compaction_bytes: IntGaugeVec,
pub rocksdb_num_running_compactions: IntGaugeVec,
pub rocksdb_num_running_flushes: IntGaugeVec,
pub rocksdb_estimate_oldest_key_time: IntGaugeVec,
Expand Down Expand Up @@ -198,6 +199,14 @@ impl ColumnFamilyMetrics {
registry,
)
.unwrap(),
rocksdb_estimate_pending_compaction_bytes: register_int_gauge_vec_with_registry!(
"rocksdb_estimate_pending_compaction_bytes",
"Estimated total number of bytes compaction needs to rewrite to get all levels down
to under target size. Not valid for other compactions than level-based.",
&["cf_name"],
registry,
)
.unwrap(),
rocksdb_num_running_compactions: register_int_gauge_vec_with_registry!(
"rocksdb_num_running_compactions",
"The number of compactions that are currently running for the column family.",
Expand Down
12 changes: 10 additions & 2 deletions crates/typed-store/src/rocks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ impl MetricConf {
}
}
}
const CF_METRICS_REPORT_PERIOD_MILLIS: u64 = 1000;
const CF_METRICS_REPORT_PERIOD_SECS: u64 = 30;
const METRICS_ERROR: i64 = -1;

/// An interface to a rocksDB database, keyed by a columnfamily
Expand Down Expand Up @@ -740,7 +740,7 @@ impl<K, V> DBMap<K, V> {
if !is_deprecated {
tokio::task::spawn(async move {
let mut interval =
tokio::time::interval(Duration::from_millis(CF_METRICS_REPORT_PERIOD_MILLIS));
tokio::time::interval(Duration::from_secs(CF_METRICS_REPORT_PERIOD_SECS));
loop {
tokio::select! {
_ = interval.tick() => {
Expand Down Expand Up @@ -1079,6 +1079,14 @@ impl<K, V> DBMap<K, V> {
Self::get_int_property(rocksdb, &cf, properties::COMPACTION_PENDING)
.unwrap_or(METRICS_ERROR),
);
db_metrics
.cf_metrics
.rocksdb_estimate_pending_compaction_bytes
.with_label_values(&[cf_name])
.set(
Self::get_int_property(rocksdb, &cf, properties::ESTIMATE_PENDING_COMPACTION_BYTES)
.unwrap_or(METRICS_ERROR),
);
db_metrics
.cf_metrics
.rocksdb_num_running_compactions
Expand Down
Loading