Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
acelyc111 committed Apr 23, 2020
1 parent b0104b9 commit 7a75f76
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 33 deletions.
23 changes: 17 additions & 6 deletions src/server/info_collector.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
Expand Down
46 changes: 23 additions & 23 deletions src/server/pegasus_server_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)) {
Expand All @@ -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);

Expand Down
15 changes: 11 additions & 4 deletions src/shell/commands/table_management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 7a75f76

Please sign in to comment.