diff --git a/src/server/info_collector.h b/src/server/info_collector.h index 71781ba20c..8e3b4b59ff 100644 --- a/src/server/info_collector.h +++ b/src/server/info_collector.h @@ -31,7 +31,8 @@ class info_collector public: struct app_stat_counters { - double convert_to_1M_ratio(double hit, double total) { + double convert_to_1M_ratio(double hit, double total) + { return std::abs(total) < 1e-6 ? 0 : hit / total * 1e6; } @@ -58,15 +59,25 @@ class info_collector row_stats.total_recent_write_throttling_reject_count); storage_mb->set(row_stats.total_storage_mb); storage_count->set(row_stats.total_storage_count); - rdb_block_cache_hit_rate->set(convert_to_1M_ratio(row_stats.total_rdb_block_cache_hit_count, row_stats.total_rdb_block_cache_total_count)); + rdb_block_cache_hit_rate->set( + convert_to_1M_ratio(row_stats.total_rdb_block_cache_hit_count, + row_stats.total_rdb_block_cache_total_count)); rdb_index_and_filter_blocks_mem_usage->set( row_stats.total_rdb_index_and_filter_blocks_mem_usage); rdb_memtable_mem_usage->set(row_stats.total_rdb_memtable_mem_usage); rdb_estimate_num_keys->set(row_stats.total_rdb_estimate_num_keys); - rdb_bf_seek_negatives_rate->set(convert_to_1M_ratio(row_stats.total_rdb_bf_seek_negatives, row_stats.total_rdb_bf_seek_total)); - rdb_bf_point_negatives_rate->set(convert_to_1M_ratio(row_stats.total_rdb_bf_point_negatives, row_stats.total_rdb_bf_point_negatives + row_stats.total_rdb_bf_point_positive_total)); - rdb_bf_point_false_positive_rate->set(convert_to_1M_ratio( - row_stats.total_rdb_bf_point_positive_total - row_stats.total_rdb_bf_point_positive_true, (row_stats.total_rdb_bf_point_positive_total - row_stats.total_rdb_bf_point_positive_true) + row_stats.total_rdb_bf_point_negatives)); + rdb_bf_seek_negatives_rate->set(convert_to_1M_ratio( + row_stats.total_rdb_bf_seek_negatives, row_stats.total_rdb_bf_seek_total)); + rdb_bf_point_negatives_rate->set( + convert_to_1M_ratio(row_stats.total_rdb_bf_point_negatives, + row_stats.total_rdb_bf_point_negatives + + row_stats.total_rdb_bf_point_positive_total)); + rdb_bf_point_false_positive_rate->set( + convert_to_1M_ratio(row_stats.total_rdb_bf_point_positive_total - + row_stats.total_rdb_bf_point_positive_true, + (row_stats.total_rdb_bf_point_positive_total - + row_stats.total_rdb_bf_point_positive_true) + + row_stats.total_rdb_bf_point_negatives)); read_qps->set(row_stats.get_total_read_qps()); write_qps->set(row_stats.get_total_write_qps()); backup_request_qps->set(row_stats.total_backup_request_qps); diff --git a/src/server/pegasus_server_impl.cpp b/src/server/pegasus_server_impl.cpp index 50ac5324fb..9d007ae2b4 100644 --- a/src/server/pegasus_server_impl.cpp +++ b/src/server/pegasus_server_impl.cpp @@ -434,38 +434,35 @@ pegasus_server_impl::pegasus_server_impl(dsn::replication::replica *r) snprintf(name, 255, "rdb.bf_seek_negatives@%s", str_gpid.c_str()); _pfc_rdb_bf_seek_negatives.init_app_counter( - "app.pegasus", - name, - COUNTER_TYPE_NUMBER, - "statistics the number of times bloom filter was checked before creating iterator on a file and useful in avoiding iterator creation (and thus likely IOPs)"); + "app.pegasus", name, COUNTER_TYPE_NUMBER, "statistics the number of times bloom filter was " + "checked before creating iterator on a file and " + "useful in avoiding iterator creation (and thus " + "likely IOPs)"); snprintf(name, 255, "rdb.bf_seek_total@%s", str_gpid.c_str()); _pfc_rdb_bf_seek_total.init_app_counter( - "app.pegasus", - name, - COUNTER_TYPE_NUMBER, - "statistics the number of times bloom filter was checked before creating iterator on a file"); + "app.pegasus", name, COUNTER_TYPE_NUMBER, "statistics the number of times bloom filter was " + "checked before creating iterator on a file"); snprintf(name, 255, "rdb.bf_point_positive_true@%s", str_gpid.c_str()); _pfc_rdb_bf_point_positive_true.init_app_counter( - "app.pegasus", - name, - COUNTER_TYPE_NUMBER, - "statistics the number of times bloom filter has avoided file reads, i.e., negatives"); + "app.pegasus", + name, + COUNTER_TYPE_NUMBER, + "statistics the number of times bloom filter has avoided file reads, i.e., negatives"); snprintf(name, 255, "rdb.bf_point_positive_total@%s", str_gpid.c_str()); _pfc_rdb_bf_point_positive_total.init_app_counter( - "app.pegasus", - name, - COUNTER_TYPE_NUMBER, - "statistics the number of times bloom FullFilter has not avoided the reads"); + "app.pegasus", + name, + COUNTER_TYPE_NUMBER, + "statistics the number of times bloom FullFilter has not avoided the reads"); snprintf(name, 255, "rdb.bf_point_negatives@%s", str_gpid.c_str()); _pfc_rdb_bf_point_negatives.init_app_counter( - "app.pegasus", - name, - COUNTER_TYPE_NUMBER, - "statistics the number of times bloom FullFilter has not avoided the reads and data actually exist"); + "app.pegasus", name, COUNTER_TYPE_NUMBER, "statistics the number of times bloom FullFilter " + "has not avoided the reads and data actually " + "exist"); } void pegasus_server_impl::parse_checkpoints() @@ -2489,7 +2486,8 @@ void pegasus_server_impl::update_replica_rocksdb_statistics() } // Update _pfc_rdb_estimate_num_keys - // NOTE: for the same n kv pairs, kEstimateNumKeys will be counted n times, you need compaction to + // NOTE: for the same n kv pairs, kEstimateNumKeys will be counted n times, you need compaction + // to // remove duplicate if (_db->GetProperty(_data_cf, rocksdb::DB::Properties::kEstimateNumKeys, &str_val) && dsn::buf2uint64(str_val, val)) { @@ -2508,12 +2506,14 @@ void pegasus_server_impl::update_replica_rocksdb_statistics() dinfo_replica("_pfc_rdb_bf_seek_total: {}", bf_seek_total); // Update _pfc_rdb_bf_point_positive_true - uint64_t bf_point_positive_true = _statistics->getTickerCount(rocksdb::BLOOM_FILTER_FULL_TRUE_POSITIVE); + uint64_t bf_point_positive_true = + _statistics->getTickerCount(rocksdb::BLOOM_FILTER_FULL_TRUE_POSITIVE); _pfc_rdb_bf_point_positive_true->set(bf_point_positive_true); dinfo_replica("_pfc_rdb_bf_point_positive_true: {}", bf_point_positive_true); // Update _pfc_rdb_bf_point_positive_total - uint64_t bf_point_positive_total = _statistics->getTickerCount(rocksdb::BLOOM_FILTER_FULL_POSITIVE); + uint64_t bf_point_positive_total = + _statistics->getTickerCount(rocksdb::BLOOM_FILTER_FULL_POSITIVE); _pfc_rdb_bf_point_positive_total->set(bf_point_positive_total); dinfo_replica("_pfc_rdb_bf_point_positive_total: {}", bf_point_positive_total); diff --git a/src/shell/commands/table_management.cpp b/src/shell/commands/table_management.cpp index eb50ee527b..2adad8a018 100644 --- a/src/shell/commands/table_management.cpp +++ b/src/shell/commands/table_management.cpp @@ -4,7 +4,8 @@ #include "shell/commands.h" -double convert_to_ratio(double hit, double total) { +double convert_to_ratio(double hit, double total) +{ return std::abs(total) < 1e-6 ? 0 : hit / total; } @@ -582,10 +583,16 @@ bool app_stat(command_executor *e, shell_context *sc, arguments args) tp.append_data(row.rdb_memtable_mem_usage / (1 << 20U)); tp.append_data(row.rdb_index_and_filter_blocks_mem_usage / (1 << 20U)); } - tp.append_data(convert_to_ratio(row.rdb_block_cache_hit_count, row.rdb_block_cache_total_count)); + tp.append_data( + convert_to_ratio(row.rdb_block_cache_hit_count, row.rdb_block_cache_total_count)); tp.append_data(convert_to_ratio(row.rdb_bf_seek_negatives, row.rdb_bf_seek_total)); - tp.append_data(convert_to_ratio(row.rdb_bf_point_negatives, row.rdb_bf_point_negatives + row.rdb_bf_point_positive_total)); - tp.append_data(convert_to_ratio(row.rdb_bf_point_positive_total - row.rdb_bf_point_positive_true, (row.rdb_bf_point_positive_total - row.rdb_bf_point_positive_true) + row.rdb_bf_point_negatives)); + tp.append_data( + convert_to_ratio(row.rdb_bf_point_negatives, + row.rdb_bf_point_negatives + row.rdb_bf_point_positive_total)); + tp.append_data( + convert_to_ratio(row.rdb_bf_point_positive_total - row.rdb_bf_point_positive_true, + (row.rdb_bf_point_positive_total - row.rdb_bf_point_positive_true) + + row.rdb_bf_point_negatives)); } tp.output(out, json ? tp_output_format::kJsonPretty : tp_output_format::kTabular);