From aff84fe2ecdb33c1b0035f15a6755aa0b5693f30 Mon Sep 17 00:00:00 2001 From: mwtian <81660174+mwtian@users.noreply.github.com> Date: Thu, 5 Sep 2024 13:41:06 -0700 Subject: [PATCH] [rocksdb] add metric for num level 0 files (#19230) ## Description Too many level 0 files can be a trigger to write stall & stop as well ## Test plan CI --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] Indexer: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: - [ ] REST API: --- crates/typed-store/src/metrics.rs | 8 ++++++++ crates/typed-store/src/rocks/mod.rs | 8 ++++++++ deny.toml | 2 ++ 3 files changed, 18 insertions(+) diff --git a/crates/typed-store/src/metrics.rs b/crates/typed-store/src/metrics.rs index 826f9a3f46e29..76e23386594b1 100644 --- a/crates/typed-store/src/metrics.rs +++ b/crates/typed-store/src/metrics.rs @@ -78,6 +78,7 @@ pub struct ColumnFamilyMetrics { pub rocksdb_total_sst_files_size: IntGaugeVec, pub rocksdb_total_blob_files_size: IntGaugeVec, pub rocksdb_total_num_files: IntGaugeVec, + pub rocksdb_num_level0_files: IntGaugeVec, pub rocksdb_current_size_active_mem_tables: IntGaugeVec, pub rocksdb_size_all_mem_tables: IntGaugeVec, pub rocksdb_num_snapshots: IntGaugeVec, @@ -124,6 +125,13 @@ impl ColumnFamilyMetrics { registry, ) .unwrap(), + rocksdb_num_level0_files: register_int_gauge_vec_with_registry!( + "rocksdb_num_level0_files", + "Number of level 0 files in the column family", + &["cf_name"], + registry, + ) + .unwrap(), rocksdb_current_size_active_mem_tables: register_int_gauge_vec_with_registry!( "rocksdb_current_size_active_mem_tables", "The current approximate size of active memtable (bytes).", diff --git a/crates/typed-store/src/rocks/mod.rs b/crates/typed-store/src/rocks/mod.rs index d794cbfc260ec..5f65067cc4525 100644 --- a/crates/typed-store/src/rocks/mod.rs +++ b/crates/typed-store/src/rocks/mod.rs @@ -1006,6 +1006,14 @@ impl DBMap { .rocksdb_total_num_files .with_label_values(&[cf_name]) .set(total_num_files); + db_metrics + .cf_metrics + .rocksdb_num_level0_files + .with_label_values(&[cf_name]) + .set( + Self::get_int_property(rocksdb, &cf, &num_files_at_level(0)) + .unwrap_or(METRICS_ERROR), + ); db_metrics .cf_metrics .rocksdb_current_size_active_mem_tables diff --git a/deny.toml b/deny.toml index b1f837e63143e..c5b514a742b35 100644 --- a/deny.toml +++ b/deny.toml @@ -34,6 +34,8 @@ ignore = [ "RUSTSEC-2024-0336", # allow yaml-rust being unmaintained "RUSTSEC-2024-0320", + # allow unmaintained proc-macro-error used in transitive dependencies + "RUSTSEC-2024-0370", ] # Threshold for security vulnerabilities, any vulnerability with a CVSS score # lower than the range specified will be ignored. Note that ignored advisories