This is an automated email from the ASF dual-hosted git repository.

yuchenhe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pegasus.git


The following commit(s) were added to refs/heads/master by this push:
     new 4854738  feat: support table level rocksdb compaction perfcounter 
(#806)
4854738 is described below

commit 4854738a29457b2f61e36da5c444956a3c3f6f19
Author: Jiashuo <[email protected]>
AuthorDate: Tue Aug 31 16:41:55 2021 +0800

    feat: support table level rocksdb compaction perfcounter (#806)
---
 src/server/info_collector.cpp         |  2 ++
 src/server/info_collector.h           |  4 ++++
 src/server/pegasus_event_listener.cpp | 18 ++++++++++++++++++
 src/server/pegasus_event_listener.h   |  4 ++++
 src/shell/command_helper.h            |  8 ++++++++
 5 files changed, 36 insertions(+)

diff --git a/src/server/info_collector.cpp b/src/server/info_collector.cpp
index ec46d15..6de9b5f 100644
--- a/src/server/info_collector.cpp
+++ b/src/server/info_collector.cpp
@@ -245,6 +245,8 @@ info_collector::app_stat_counters 
*info_collector::get_app_counters(const std::s
     INIT_COUNTER(check_and_mutate_bytes);
     INIT_COUNTER(read_bytes);
     INIT_COUNTER(write_bytes);
+    INIT_COUNTER(recent_rdb_compaction_input_bytes);
+    INIT_COUNTER(recent_rdb_compaction_output_bytes);
     INIT_COUNTER(rdb_read_l2andup_hit_rate);
     INIT_COUNTER(rdb_read_l1_hit_rate);
     INIT_COUNTER(rdb_read_l0_hit_rate);
diff --git a/src/server/info_collector.h b/src/server/info_collector.h
index c812ed2..9f26901 100644
--- a/src/server/info_collector.h
+++ b/src/server/info_collector.h
@@ -114,6 +114,8 @@ public:
             check_and_mutate_bytes->set(row_stats.check_and_mutate_bytes);
             read_bytes->set(row_stats.get_total_read_bytes());
             write_bytes->set(row_stats.get_total_write_bytes());
+            
recent_rdb_compaction_input_bytes->set(row_stats.recent_rdb_compaction_input_bytes);
+            
recent_rdb_compaction_output_bytes->set(row_stats.recent_rdb_compaction_output_bytes);
             rdb_read_l2andup_hit_rate->set(convert_to_1M_ratio(
                 row_stats.rdb_read_l2andup_hit_count, 
row_stats.rdb_block_cache_total_count));
             
rdb_read_l1_hit_rate->set(convert_to_1M_ratio(row_stats.rdb_read_l1_hit_count,
@@ -180,6 +182,8 @@ public:
         ::dsn::perf_counter_wrapper check_and_mutate_bytes;
         ::dsn::perf_counter_wrapper read_bytes;
         ::dsn::perf_counter_wrapper write_bytes;
+        ::dsn::perf_counter_wrapper recent_rdb_compaction_input_bytes;
+        ::dsn::perf_counter_wrapper recent_rdb_compaction_output_bytes;
         ::dsn::perf_counter_wrapper rdb_read_l2andup_hit_rate;
         ::dsn::perf_counter_wrapper rdb_read_l1_hit_rate;
         ::dsn::perf_counter_wrapper rdb_read_l0_hit_rate;
diff --git a/src/server/pegasus_event_listener.cpp 
b/src/server/pegasus_event_listener.cpp
index 3360db4..7354b31 100644
--- a/src/server/pegasus_event_listener.cpp
+++ b/src/server/pegasus_event_listener.cpp
@@ -58,6 +58,21 @@ pegasus_event_listener::pegasus_event_listener(replica_base 
*r) : replica_base(r
         "recent.write.change.stopped.count",
         COUNTER_TYPE_VOLATILE_NUMBER,
         "rocksdb recent write change stopped count");
+
+    // replica-level perfcounter
+    std::string counter_str = 
fmt::format("recent_rdb_compaction_input_bytes@{}", r->get_gpid());
+    _pfc_recent_rdb_compaction_input_bytes.init_app_counter(
+        "app.pegasus",
+        counter_str.c_str(),
+        COUNTER_TYPE_VOLATILE_NUMBER,
+        "rocksdb recent compaction input bytes");
+
+    counter_str = fmt::format("recent_rdb_compaction_output_bytes@{}", 
r->get_gpid());
+    _pfc_recent_rdb_compaction_output_bytes.init_app_counter(
+        "app.pegasus",
+        counter_str.c_str(),
+        COUNTER_TYPE_VOLATILE_NUMBER,
+        "rocksdb recent compaction output bytes");
 }
 
 void pegasus_event_listener::OnFlushCompleted(rocksdb::DB *db,
@@ -73,6 +88,9 @@ void 
pegasus_event_listener::OnCompactionCompleted(rocksdb::DB *db,
     _pfc_recent_compaction_completed_count->increment();
     _pfc_recent_compaction_input_bytes->add(ci.stats.total_input_bytes);
     _pfc_recent_compaction_output_bytes->add(ci.stats.total_output_bytes);
+
+    _pfc_recent_rdb_compaction_input_bytes->add(ci.stats.total_input_bytes);
+    _pfc_recent_rdb_compaction_output_bytes->add(ci.stats.total_output_bytes);
 }
 
 void pegasus_event_listener::OnStallConditionsChanged(const 
rocksdb::WriteStallInfo &info)
diff --git a/src/server/pegasus_event_listener.h 
b/src/server/pegasus_event_listener.h
index 4d03c6a..bb5b483 100644
--- a/src/server/pegasus_event_listener.h
+++ b/src/server/pegasus_event_listener.h
@@ -47,6 +47,10 @@ private:
     ::dsn::perf_counter_wrapper _pfc_recent_compaction_output_bytes;
     ::dsn::perf_counter_wrapper _pfc_recent_write_change_delayed_count;
     ::dsn::perf_counter_wrapper _pfc_recent_write_change_stopped_count;
+
+    // replica-level perfcounter
+    ::dsn::perf_counter_wrapper _pfc_recent_rdb_compaction_input_bytes;
+    ::dsn::perf_counter_wrapper _pfc_recent_rdb_compaction_output_bytes;
 };
 
 } // namespace server
diff --git a/src/shell/command_helper.h b/src/shell/command_helper.h
index c075d50..a76ac41 100644
--- a/src/shell/command_helper.h
+++ b/src/shell/command_helper.h
@@ -652,6 +652,8 @@ struct row_data
         multi_put_bytes += row.multi_put_bytes;
         check_and_set_bytes += row.check_and_set_bytes;
         check_and_mutate_bytes += row.check_and_mutate_bytes;
+        recent_rdb_compaction_input_bytes += 
row.recent_rdb_compaction_input_bytes;
+        recent_rdb_compaction_output_bytes += 
row.recent_rdb_compaction_output_bytes;
         rdb_read_l2andup_hit_count += row.rdb_read_l2andup_hit_count;
         rdb_read_l1_hit_count += row.rdb_read_l1_hit_count;
         rdb_read_l0_hit_count += row.rdb_read_l0_hit_count;
@@ -712,6 +714,8 @@ struct row_data
     double multi_put_bytes = 0;
     double check_and_set_bytes = 0;
     double check_and_mutate_bytes = 0;
+    double recent_rdb_compaction_input_bytes = 0;
+    double recent_rdb_compaction_output_bytes = 0;
     double rdb_read_l2andup_hit_count = 0;
     double rdb_read_l1_hit_count = 0;
     double rdb_read_l0_hit_count = 0;
@@ -821,6 +825,10 @@ update_app_pegasus_perf_counter(row_data &row, const 
std::string &counter_name,
         row.check_and_set_bytes += value;
     else if (counter_name == "check_and_mutate_bytes")
         row.check_and_mutate_bytes += value;
+    else if (counter_name == "recent_rdb_compaction_input_bytes")
+        row.recent_rdb_compaction_input_bytes += value;
+    else if (counter_name == "recent_rdb_compaction_output_bytes")
+        row.recent_rdb_compaction_output_bytes += value;
     else if (counter_name == "rdb.read_l2andup_hit_count")
         row.rdb_read_l2andup_hit_count += value;
     else if (counter_name == "rdb.read_l1_hit_count")

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to