Skip to content

Commit

Permalink
[rocksdb] add metric for num level 0 files (#19230)
Browse files Browse the repository at this point in the history
## 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:
  • Loading branch information
mwtian authored and suiwombat committed Sep 16, 2024
1 parent 5430b3f commit aff84fe
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/typed-store/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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).",
Expand Down
8 changes: 8 additions & 0 deletions crates/typed-store/src/rocks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,14 @@ impl<K, V> DBMap<K, V> {
.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
Expand Down
2 changes: 2 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aff84fe

Please sign in to comment.