]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/osd/pg: record client requests' metrics in DynamicPerfStats
authorXuehan Xu <xuxuehan@qianxin.com>
Thu, 26 Dec 2024 08:08:23 +0000 (16:08 +0800)
committerXuehan Xu <xuxuehan@qianxin.com>
Fri, 7 Feb 2025 03:39:57 +0000 (11:39 +0800)
Signed-off-by: Xuehan Xu <xuxuehan@qianxin.com>
src/crimson/osd/ops_executer.h
src/crimson/osd/osd_operations/client_request.cc
src/crimson/osd/osd_operations/client_request.h
src/crimson/osd/pg.h

index f5554bd69191ff79c91866da5dd9f6401e2848f2..6be1f09eab403c6e53edf500bafa2b27bd430654 100644 (file)
@@ -169,6 +169,10 @@ public:
       IOInterruptCondition, osd_op_errorator>;
 
   object_stat_sum_t delta_stats;
+
+  size_t get_bytes_written() {
+    return txn.get_num_bytes();
+  }
 private:
   // with_effect can be used to schedule operations to be performed
   // at commit time.  effects will be discarded if the operation does
index 4f4283ea6f6e3427ba9e157341a0b3b5143a799a..24d602a0cde5f572363ad4e59fa199230ebeee62 100644 (file)
@@ -63,6 +63,7 @@ ClientRequest::ClientRequest(
   : shard_services(&_shard_services),
     l_conn(std::move(conn)),
     m(std::move(m)),
+    begin_time(std::chrono::steady_clock::now()),
     instance_handle(new instance_handle_t)
 {}
 
@@ -525,6 +526,7 @@ ClientRequest::do_process(
     co_return;
   }
 
+  size_t inb = 0, outb = 0;
   {
     auto all_completed = interruptor::now();
     if (ret) {
@@ -540,6 +542,7 @@ ClientRequest::do_process(
       // simply return the error below, leaving all_completed alone
     } else {
       auto submitted = interruptor::now();
+      inb = ox.get_bytes_written();
       std::tie(submitted, all_completed) = co_await pg->submit_executer(
        std::move(ox), m->ops);
       co_await std::move(submitted);
@@ -573,9 +576,15 @@ ClientRequest::do_process(
          reply->set_result(osdop.rval);
          break;
        }
+        outb += osdop.outdata.length();
       }
     }
 
+    pg->add_client_request_lat(
+      *this,
+      inb,
+      outb,
+      utime_t{std::chrono::steady_clock::now() - begin_time});
     reply->set_enoent_reply_versions(
       pg->peering_state.get_info().last_update,
       pg->peering_state.get_info().last_user_version);
index 10b71fc696b4cc87803ad30ef7ed0dbc6a66e4e6..d624f8c1685f0ca48f10ce24ab111c2c178ad88f 100644 (file)
@@ -41,12 +41,25 @@ class ClientRequest final : public PhasedOperationT<ClientRequest>,
   OpInfo op_info;
   seastar::promise<> on_complete;
   unsigned instance_id = 0;
+  std::chrono::time_point<std::chrono::steady_clock> begin_time;
 
 public:
   epoch_t get_epoch_sent_at() const {
     return m->get_map_epoch();
   }
 
+  bool may_write() const { return op_info.may_write(); }
+  bool may_cache() const { return op_info.may_cache(); }
+  bool may_read() const { return op_info.may_read(); }
+  template <typename T>
+  T* get_req() const {
+    static_assert(std::is_same_v<T, MOSDOp>);
+    return m.get();
+  }
+  const crimson::net::ConnectionRef &get_connection() const {
+    return l_conn;
+  }
+
   /**
    * instance_handle_t
    *
index df19ee92b3a88bf6e177f85d619135ca1f742a48..ca84b24583e2c914df004077458797d42793ebda 100644 (file)
@@ -21,6 +21,7 @@
 #include "crimson/osd/object_context.h"
 #include "osd/PeeringState.h"
 #include "osd/SnapMapper.h"
+#include "osd/DynamicPerfStats.h"
 
 #include "crimson/common/interruptible_future.h"
 #include "crimson/common/log.h"
@@ -765,8 +766,16 @@ public:
 
 private:
   std::optional<pg_stat_t> pg_stats;
+  DynamicPerfStats dp_stats;
 
 public:
+  void add_client_request_lat(
+    const ClientRequest& req,
+    size_t inb,
+    size_t outb,
+    const utime_t &lat) {
+    dp_stats.add(pg_whoami.osd, get_info(), req, inb, outb, lat);
+  }
   OSDriver &get_osdriver() final {
     return osdriver;
   }