]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/d4n: adding perfcounters for d4n cache hits, misses and evictions (LFUDA).
authorPritha Srivastava <prsrivas@redhat.com>
Thu, 30 May 2024 04:27:49 +0000 (09:57 +0530)
committerPritha Srivastava <prsrivas@redhat.com>
Mon, 21 Apr 2025 04:04:07 +0000 (09:34 +0530)
Signed-off-by: Pritha Srivastava <prsrivas@redhat.com>
src/rgw/driver/d4n/d4n_policy.cc
src/rgw/driver/d4n/rgw_sal_d4n.cc
src/rgw/driver/d4n/rgw_sal_d4n.h
src/rgw/rgw_perf_counters.cc
src/rgw/rgw_perf_counters.h

index cf8095b207abc2639529cbeae95b2acbbc5edda6..f73e7d3e66c6e1d53c14a15fae67de37bd985d8e 100644 (file)
@@ -2,7 +2,8 @@
 
 #include "../../../common/async/yield_context.h"
 #include "common/async/blocked_completion.h"
-#include "common/dout.h" 
+#include "common/dout.h"
+#include "rgw_perf_counters.h"
 
 namespace rgw { namespace d4n {
 
@@ -324,6 +325,10 @@ int LFUDAPolicy::eviction(const DoutPrefixProvider* dpp, uint64_t size, optional
     age = std::max(it->second->localWeight, age);
 
     erase(dpp, key, y);
+
+    if (perfcounter) {
+      perfcounter->inc(l_rgw_d4n_cache_evictions);
+    }
     freeSpace = cacheDriver->get_free_space(dpp);
   }
   
index df8b3f5513a729bf59ff637fa11f0c746cec9a88..ad6933a01b206defb06b2cb07ca01332616531e2 100644 (file)
@@ -13,6 +13,7 @@
  *
  */
 
+#include "rgw_perf_counters.h"
 #include "rgw_sal_d4n.h"
 
 namespace rgw { namespace sal {
@@ -514,6 +515,9 @@ int D4NFilterObject::get_obj_attrs(optional_yield y, const DoutPrefixProvider* d
     is_latest_version = false;
   }
   if (!get_obj_attrs_from_cache(dpp, y)) {
+    if(perfcounter) {
+      perfcounter->inc(l_rgw_d4n_cache_misses);
+    }
     std::string head_oid_in_cache;
     rgw::sal::Attrs attrs;
     std::string version;
@@ -563,6 +567,10 @@ int D4NFilterObject::get_obj_attrs(optional_yield y, const DoutPrefixProvider* d
     } else {
       ldpp_dout(dpp, 0) << "D4NFilterObject::" << __func__ << "(): failed to cache head object in cache backend, ret=" << ret << dendl;
     }
+  } else {
+    if(perfcounter) {
+      perfcounter->inc(l_rgw_d4n_cache_hits);
+    }
   }
 
   return 0;
@@ -676,6 +684,9 @@ int D4NFilterObject::D4NFilterReadOp::prepare(optional_yield y, const DoutPrefix
     is_latest_version = false;
   }
   if (!source->get_obj_attrs_from_cache(dpp, y)) {
+    if(perfcounter) {
+      perfcounter->inc(l_rgw_d4n_cache_misses);
+    }
     std::string head_oid_in_cache;
     rgw::sal::Attrs attrs;
     std::string version;
@@ -733,6 +744,10 @@ int D4NFilterObject::D4NFilterReadOp::prepare(optional_yield y, const DoutPrefix
     } else {
       ldpp_dout(dpp, 0) << "D4NFilterObject::" << __func__ << "(): failed to cache head object during eviction, ret=" << ret << dendl;
     }
+  } else {
+    if(perfcounter) {
+      perfcounter->inc(l_rgw_d4n_cache_hits);
+    }
   }
   
   return 0;
@@ -840,6 +855,9 @@ int D4NFilterObject::D4NFilterReadOp::flush(const DoutPrefixProvider* dpp, rgw::
   
     offset += bl.length();
     completed.pop_front_and_dispose(std::default_delete<rgw::AioResultEntry>{});
+    if(perfcounter) {
+      perfcounter->inc(l_rgw_d4n_cache_hits);
+    }
   }
 
   ldpp_dout(dpp, 20) << "D4NFilterObject::returning from flush:: " << dendl;
@@ -1127,6 +1145,13 @@ int D4NFilterObject::D4NFilterReadOp::iterate(const DoutPrefixProvider* dpp, int
 
   this->cb->set_ofs(ofs);
   auto r = next->iterate(dpp, ofs, end, this->cb.get(), y);
+
+  //calculate the number of blocks read from backend store, and increment the perfcounter using that
+  if(perfcounter) {
+    uint64_t len_to_read_from_store = ((end - ofs) + 1);
+    uint64_t num_blocks = (len_to_read_from_store%obj_max_req_size) == 0 ? len_to_read_from_store/obj_max_req_size : (len_to_read_from_store/obj_max_req_size) + 1;
+    perfcounter->inc(l_rgw_d4n_cache_misses, num_blocks);
+  }
   
   if (r < 0) {
     ldpp_dout(dpp, 0) << "D4NFilterObject::iterate:: " << __func__ << "(): Error: failed to fetch object from backend store, ret=" << r << dendl;
index a38012fb81373e58f3638e3a7a3e09dac5bbed30..bdd5bef90a9173e269c770cab0eaef6a8a1aa31f 100644 (file)
@@ -109,6 +109,7 @@ class D4NFilterObject : public FilterObject {
     rgw::sal::Object* dest_object{nullptr}; //for copy-object
     rgw::sal::Bucket* dest_bucket{nullptr}; //for copy-object
     std::string dest_version;
+
   public:
     struct D4NFilterReadOp : FilterReadOp {
       public:
index d316476a27b71a859ade99d08981eaf358f70f44..8616293c351886eecaa7063716bb7b7d5576a52b 100644 (file)
@@ -59,6 +59,10 @@ void add_rgw_frontend_counters(PerfCountersBuilder *pcb) {
   pcb->add_u64_counter(l_rgw_lua_script_ok, "lua_script_ok", "Successful executions of Lua scripts");
   pcb->add_u64_counter(l_rgw_lua_script_fail, "lua_script_fail", "Failed executions of Lua scripts");
   pcb->add_u64(l_rgw_lua_current_vms, "lua_current_vms", "Number of Lua VMs currently being executed");
+
+  pcb->add_u64_counter(l_rgw_d4n_cache_hits, "d4n_cache_hits", "D4N cache hits");
+  pcb->add_u64_counter(l_rgw_d4n_cache_misses, "d4n_cache_misses", "D4N cache misses");
+  pcb->add_u64_counter(l_rgw_d4n_cache_evictions, "d4n_cache_evictions", "D4N cache evictions");
 }
 
 void add_rgw_op_counters(PerfCountersBuilder *lpcb) {
index 7eb11c926c17acc071e554cf1828cbb9a77f1dd8..5125d114989797030bcaa13cd80de06a09c0187f 100644 (file)
@@ -49,6 +49,10 @@ enum {
   l_rgw_lua_script_ok,
   l_rgw_lua_script_fail,
 
+  l_rgw_d4n_cache_hits,
+  l_rgw_d4n_cache_misses,
+  l_rgw_d4n_cache_evictions,
+
   l_rgw_last,
 };