diff --git a/ledger/src/blockstore_db.rs b/ledger/src/blockstore_db.rs index b06d6da640..17061ecade 100644 --- a/ledger/src/blockstore_db.rs +++ b/ledger/src/blockstore_db.rs @@ -9,7 +9,6 @@ use { blockstore_options::{ AccessType, BlockstoreOptions, LedgerColumnOptions, ShredStorageType, }, - rocksdb_metric_header, }, bincode::{deserialize, serialize}, byteorder::{BigEndian, ByteOrder}, @@ -492,12 +491,10 @@ impl Rocks { let result = self.db.write(batch); if let Some(op_start_instant) = op_start_instant { report_rocksdb_write_perf( + "write_batch", // We use write_batch as cf_name for write batch. + "write_batch", // op_name &op_start_instant.elapsed(), - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=write_batch", - "write_batch", - self.column_options - ), + &self.column_options, ); } match result { @@ -1144,10 +1141,7 @@ where ); let result = self.backend.get_cf(self.handle(), &C::key(key)); if let Some(op_start_instant) = is_perf_enabled { - report_rocksdb_read_perf( - &op_start_instant.elapsed(), - C::rocksdb_get_perf_metric_header(&self.column_options), - ); + report_rocksdb_read_perf(C::NAME, &op_start_instant.elapsed(), &self.column_options); } result } @@ -1226,8 +1220,10 @@ where let result = self.backend.put_cf(self.handle(), &C::key(key), value); if let Some(op_start_instant) = is_perf_enabled { report_rocksdb_write_perf( + C::NAME, + "put", &op_start_instant.elapsed(), - C::rocksdb_put_perf_metric_header(&self.column_options), + &self.column_options, ); } result @@ -1260,10 +1256,7 @@ where } if let Some(op_start_instant) = is_perf_enabled { - report_rocksdb_read_perf( - &op_start_instant.elapsed(), - C::rocksdb_get_perf_metric_header(&self.column_options), - ); + report_rocksdb_read_perf(C::NAME, &op_start_instant.elapsed(), &self.column_options); } result } @@ -1281,8 +1274,10 @@ where if let Some(op_start_instant) = is_perf_enabled { report_rocksdb_write_perf( + C::NAME, + "put", &op_start_instant.elapsed(), - C::rocksdb_put_perf_metric_header(&self.column_options), + &self.column_options, ); } result @@ -1296,8 +1291,10 @@ where let result = self.backend.delete_cf(self.handle(), &C::key(key)); if let Some(op_start_instant) = is_perf_enabled { report_rocksdb_write_perf( + C::NAME, + "delete", &op_start_instant.elapsed(), - C::rocksdb_delete_perf_metric_header(&self.column_options), + &self.column_options, ); } result @@ -1318,10 +1315,7 @@ where ); let result = self.backend.get_cf(self.handle(), &C::key(key)); if let Some(op_start_instant) = is_perf_enabled { - report_rocksdb_read_perf( - &op_start_instant.elapsed(), - C::rocksdb_get_perf_metric_header(&self.column_options), - ); + report_rocksdb_read_perf(C::NAME, &op_start_instant.elapsed(), &self.column_options); } if let Some(serialized_value) = result? { @@ -1342,10 +1336,7 @@ where ); let result = self.backend.get_cf(self.handle(), &C::key(key)); if let Some(op_start_instant) = is_perf_enabled { - report_rocksdb_read_perf( - &op_start_instant.elapsed(), - C::rocksdb_get_perf_metric_header(&self.column_options), - ); + report_rocksdb_read_perf(C::NAME, &op_start_instant.elapsed(), &self.column_options); } if let Some(serialized_value) = result? { @@ -1366,8 +1357,10 @@ where let result = self.backend.put_cf(self.handle(), &C::key(key), &buf); if let Some(op_start_instant) = is_perf_enabled { report_rocksdb_write_perf( + C::NAME, + "put", &op_start_instant.elapsed(), - C::rocksdb_put_perf_metric_header(&self.column_options), + &self.column_options, ); } diff --git a/ledger/src/blockstore_metrics.rs b/ledger/src/blockstore_metrics.rs index 152fcd5f39..32ce40a78e 100644 --- a/ledger/src/blockstore_metrics.rs +++ b/ledger/src/blockstore_metrics.rs @@ -265,12 +265,21 @@ pub(crate) fn maybe_enable_rocksdb_perf( /// Reports the collected PerfContext and disables the PerfContext after /// reporting. -pub(crate) fn report_rocksdb_read_perf(total_op_duration: &Duration, metric_header: &'static str) { +pub(crate) fn report_rocksdb_read_perf( + cf_name: &'static str, + total_op_duration: &Duration, + column_options: &LedgerColumnOptions, +) { PER_THREAD_ROCKS_PERF_CONTEXT.with(|perf_context_cell| { set_perf_stats(PerfStatsLevel::Disable); let perf_context = perf_context_cell.borrow(); datapoint_info!( - metric_header, + "blockstore_rocksdb_read_perf", + // tags that support group-by operations + "op" => "get", + "cf_name" => cf_name, + "storage" => column_options.get_storage_type_string(), + "compression" => column_options.get_compression_type_string(), // total nanos spent on the entire operation. ("total_op_nanos", total_op_duration.as_nanos() as i64, i64), ( @@ -431,12 +440,22 @@ pub(crate) fn report_rocksdb_read_perf(total_op_duration: &Duration, metric_head } /// Reports the collected PerfContext and disables the PerfContext after /// reporting. -pub(crate) fn report_rocksdb_write_perf(total_op_duration: &Duration, metric_header: &'static str) { +pub(crate) fn report_rocksdb_write_perf( + cf_name: &'static str, + op_name: &'static str, + total_op_duration: &Duration, + column_options: &LedgerColumnOptions, +) { PER_THREAD_ROCKS_PERF_CONTEXT.with(|perf_context_cell| { set_perf_stats(PerfStatsLevel::Disable); let perf_context = perf_context_cell.borrow(); datapoint_info!( - metric_header, + "blockstore_rocksdb_write_perf", + // tags that support group-by operations + "op" => op_name, + "cf_name" => cf_name, + "storage" => column_options.get_storage_type_string(), + "compression" => column_options.get_compression_type_string(), // total nanos spent on the entire operation. ("total_op_nanos", total_op_duration.as_nanos() as i64, i64), // total nanos spent on writing to WAL @@ -545,10 +564,6 @@ pub trait ColumnMetrics { cf_metrics: BlockstoreRocksDbColumnFamilyMetrics, column_options: &Arc, ); - fn rocksdb_get_perf_metric_header(column_options: &Arc) -> &'static str; - fn rocksdb_put_perf_metric_header(column_options: &Arc) -> &'static str; - fn rocksdb_delete_perf_metric_header(column_options: &Arc) - -> &'static str; } impl ColumnMetrics for columns::TransactionStatus { @@ -562,29 +577,6 @@ impl ColumnMetrics for columns::TransactionStatus { column_options )); } - fn rocksdb_get_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_read_perf,op=get", - "transaction_status", - column_options - ) - } - fn rocksdb_put_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=put", - "transaction_status", - column_options - ) - } - fn rocksdb_delete_perf_metric_header( - column_options: &Arc, - ) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=delete", - "transaction_status", - column_options - ) - } } impl ColumnMetrics for columns::AddressSignatures { @@ -598,29 +590,6 @@ impl ColumnMetrics for columns::AddressSignatures { column_options )); } - fn rocksdb_get_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_read_perf,op=get", - "address_signatures", - column_options - ) - } - fn rocksdb_put_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=put", - "address_signatures", - column_options - ) - } - fn rocksdb_delete_perf_metric_header( - column_options: &Arc, - ) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=delete", - "address_signatures", - column_options - ) - } } impl ColumnMetrics for columns::TransactionMemos { @@ -634,29 +603,6 @@ impl ColumnMetrics for columns::TransactionMemos { column_options )); } - fn rocksdb_get_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_read_perf,op=get", - "transaction_memos", - column_options - ) - } - fn rocksdb_put_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=put", - "transaction_memos", - column_options - ) - } - fn rocksdb_delete_perf_metric_header( - column_options: &Arc, - ) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=delete", - "transaction_memos", - column_options - ) - } } impl ColumnMetrics for columns::TransactionStatusIndex { @@ -670,29 +616,6 @@ impl ColumnMetrics for columns::TransactionStatusIndex { column_options )); } - fn rocksdb_get_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_read_perf,op=get", - "transaction_status_index", - column_options - ) - } - fn rocksdb_put_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=put", - "transaction_status_index", - column_options - ) - } - fn rocksdb_delete_perf_metric_header( - column_options: &Arc, - ) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=delete", - "transaction_status_index", - column_options - ) - } } impl ColumnMetrics for columns::Rewards { @@ -706,29 +629,6 @@ impl ColumnMetrics for columns::Rewards { column_options )); } - fn rocksdb_get_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_read_perf,op=get", - "rewards", - column_options - ) - } - fn rocksdb_put_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=put", - "rewards", - column_options - ) - } - fn rocksdb_delete_perf_metric_header( - column_options: &Arc, - ) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=delete", - "rewards", - column_options - ) - } } impl ColumnMetrics for columns::Blocktime { @@ -742,29 +642,6 @@ impl ColumnMetrics for columns::Blocktime { column_options )); } - fn rocksdb_get_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_read_perf,op=get", - "blocktime", - column_options - ) - } - fn rocksdb_put_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=put", - "blocktime", - column_options - ) - } - fn rocksdb_delete_perf_metric_header( - column_options: &Arc, - ) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=delete", - "blocktime", - column_options - ) - } } impl ColumnMetrics for columns::PerfSamples { @@ -778,29 +655,6 @@ impl ColumnMetrics for columns::PerfSamples { column_options )); } - fn rocksdb_get_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_read_perf,op=get", - "perf_samples", - column_options - ) - } - fn rocksdb_put_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=put", - "perf_samples", - column_options - ) - } - fn rocksdb_delete_perf_metric_header( - column_options: &Arc, - ) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=delete", - "perf_samples", - column_options - ) - } } impl ColumnMetrics for columns::BlockHeight { @@ -814,29 +668,6 @@ impl ColumnMetrics for columns::BlockHeight { column_options )); } - fn rocksdb_get_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_read_perf,op=get", - "block_height", - column_options - ) - } - fn rocksdb_put_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=put", - "block_height", - column_options - ) - } - fn rocksdb_delete_perf_metric_header( - column_options: &Arc, - ) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=delete", - "block_height", - column_options - ) - } } impl ColumnMetrics for columns::ProgramCosts { @@ -850,29 +681,6 @@ impl ColumnMetrics for columns::ProgramCosts { column_options )); } - fn rocksdb_get_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_read_perf,op=get", - "program_costs", - column_options - ) - } - fn rocksdb_put_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=put", - "program_costs", - column_options - ) - } - fn rocksdb_delete_perf_metric_header( - column_options: &Arc, - ) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=delete", - "program_costs", - column_options - ) - } } impl ColumnMetrics for columns::ShredCode { @@ -886,29 +694,6 @@ impl ColumnMetrics for columns::ShredCode { column_options )); } - fn rocksdb_get_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_read_perf,op=get", - "shred_code", - column_options - ) - } - fn rocksdb_put_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=put", - "shred_code", - column_options - ) - } - fn rocksdb_delete_perf_metric_header( - column_options: &Arc, - ) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=delete", - "shred_code", - column_options - ) - } } impl ColumnMetrics for columns::ShredData { @@ -922,29 +707,6 @@ impl ColumnMetrics for columns::ShredData { column_options )); } - fn rocksdb_get_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_read_perf,op=get", - "shred_data", - column_options - ) - } - fn rocksdb_put_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=put", - "shred_data", - column_options - ) - } - fn rocksdb_delete_perf_metric_header( - column_options: &Arc, - ) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=delete", - "shred_data", - column_options - ) - } } impl ColumnMetrics for columns::Index { @@ -958,29 +720,6 @@ impl ColumnMetrics for columns::Index { column_options )); } - fn rocksdb_get_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_read_perf,op=get", - "index", - column_options - ) - } - fn rocksdb_put_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=put", - "index", - column_options - ) - } - fn rocksdb_delete_perf_metric_header( - column_options: &Arc, - ) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=delete", - "index", - column_options - ) - } } impl ColumnMetrics for columns::DeadSlots { @@ -994,29 +733,6 @@ impl ColumnMetrics for columns::DeadSlots { column_options )); } - fn rocksdb_get_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_read_perf,op=get", - "dead_slots", - column_options - ) - } - fn rocksdb_put_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=put", - "dead_slots", - column_options - ) - } - fn rocksdb_delete_perf_metric_header( - column_options: &Arc, - ) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=delete", - "dead_slots", - column_options - ) - } } impl ColumnMetrics for columns::DuplicateSlots { @@ -1030,29 +746,6 @@ impl ColumnMetrics for columns::DuplicateSlots { column_options )); } - fn rocksdb_get_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_read_perf,op=get", - "duplicate_slots", - column_options - ) - } - fn rocksdb_put_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=put", - "duplicate_slots", - column_options - ) - } - fn rocksdb_delete_perf_metric_header( - column_options: &Arc, - ) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=delete", - "duplicate_slots", - column_options - ) - } } impl ColumnMetrics for columns::Orphans { @@ -1066,29 +759,6 @@ impl ColumnMetrics for columns::Orphans { column_options )); } - fn rocksdb_get_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_read_perf,op=get", - "orphans", - column_options - ) - } - fn rocksdb_put_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=put", - "orphans", - column_options - ) - } - fn rocksdb_delete_perf_metric_header( - column_options: &Arc, - ) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=delete", - "orphans", - column_options - ) - } } impl ColumnMetrics for columns::BankHash { @@ -1102,29 +772,6 @@ impl ColumnMetrics for columns::BankHash { column_options )); } - fn rocksdb_get_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_read_perf,op=get", - "bank_hash", - column_options - ) - } - fn rocksdb_put_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=put", - "bank_hash", - column_options - ) - } - fn rocksdb_delete_perf_metric_header( - column_options: &Arc, - ) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=delete", - "bank_hash", - column_options - ) - } } impl ColumnMetrics for columns::OptimisticSlots { @@ -1138,29 +785,6 @@ impl ColumnMetrics for columns::OptimisticSlots { column_options )); } - fn rocksdb_get_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_read_perf,op=get", - "optimistic_slots", - column_options - ) - } - fn rocksdb_put_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=put", - "optimistic_slots", - column_options - ) - } - fn rocksdb_delete_perf_metric_header( - column_options: &Arc, - ) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=delete", - "optimistic_slots", - column_options - ) - } } impl ColumnMetrics for columns::Root { @@ -1174,29 +798,6 @@ impl ColumnMetrics for columns::Root { column_options )); } - fn rocksdb_get_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_read_perf,op=get", - "root", - column_options - ) - } - fn rocksdb_put_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=put", - "root", - column_options - ) - } - fn rocksdb_delete_perf_metric_header( - column_options: &Arc, - ) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=delete", - "root", - column_options - ) - } } impl ColumnMetrics for columns::SlotMeta { @@ -1210,29 +811,6 @@ impl ColumnMetrics for columns::SlotMeta { column_options )); } - fn rocksdb_get_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_read_perf,op=get", - "slot_meta", - column_options - ) - } - fn rocksdb_put_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=put", - "slot_meta", - column_options - ) - } - fn rocksdb_delete_perf_metric_header( - column_options: &Arc, - ) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=delete", - "slot_meta", - column_options - ) - } } impl ColumnMetrics for columns::ErasureMeta { @@ -1246,27 +824,4 @@ impl ColumnMetrics for columns::ErasureMeta { column_options )); } - fn rocksdb_get_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_read_perf,op=get", - "erasure_meta", - column_options - ) - } - fn rocksdb_put_perf_metric_header(column_options: &Arc) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=put", - "erasure_meta", - column_options - ) - } - fn rocksdb_delete_perf_metric_header( - column_options: &Arc, - ) -> &'static str { - rocksdb_metric_header!( - "blockstore_rocksdb_write_perf,op=delete", - "erasure_meta", - column_options - ) - } }