]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/os/seastore: measure inline/ool record header fullness
authorYingxin Cheng <yingxin.cheng@intel.com>
Mon, 11 Oct 2021 08:11:22 +0000 (16:11 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Mon, 11 Oct 2021 08:14:01 +0000 (16:14 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/cache.cc
src/crimson/os/seastore/cache.h
src/crimson/os/seastore/extent_placement_manager.cc
src/crimson/os/seastore/seastore_types.cc
src/crimson/os/seastore/seastore_types.h
src/crimson/os/seastore/transaction.h

index f7f32b8b04e403d86147733b00a7f27d1f82258e..129e7e183aa57e84bd4e28d5236ccaf9b3f3c882 100644 (file)
@@ -403,6 +403,52 @@ void Cache::register_metrics()
     );
   }
 
+  /**
+   * Record header fullness
+   */
+  auto record_type_label = sm::label("record_type");
+  using namespace std::literals::string_view_literals;
+  const string_view record_type_names[] = {
+    "INLINE"sv,
+    "OOL"sv,
+  };
+  for (auto& [src, src_label] : labels_by_src) {
+    if (src == src_t::READ) {
+      // READ transaction won't commit
+      continue;
+    }
+    auto& record_header_fullness = get_by_src(
+        stats.record_header_fullness_by_src, src);
+    for (auto& record_type_name : record_type_names) {
+      auto& fill_stat = [&record_type_name,
+                         &record_header_fullness]() -> fill_stat_t& {
+        if (record_type_name == "INLINE") {
+          return record_header_fullness.inline_stats;
+        } else {
+          assert(record_type_name == "OOL");
+          return record_header_fullness.ool_stats;
+        }
+      }();
+      metrics.add_group(
+        "cache",
+        {
+          sm::make_counter(
+            "record_header_filled_bytes",
+            fill_stat.filled_bytes,
+            sm::description("filled bytes of record header"),
+            {src_label, record_type_label(record_type_name)}
+          ),
+          sm::make_counter(
+            "record_header_total_bytes",
+            fill_stat.total_bytes,
+            sm::description("total bytes of record header"),
+            {src_label, record_type_label(record_type_name)}
+          ),
+        }
+      );
+    }
+  }
+
   /**
    * Cached extents (including placeholders)
    *
@@ -678,6 +724,11 @@ void Cache::mark_transaction_conflicted(
     efforts.num_ool_records += ool_stats.num_records;
     efforts.ool_record_overhead_bytes += ool_stats.header_bytes;
 
+    auto& record_header_fullness = get_by_src(
+        stats.record_header_fullness_by_src, t.get_src());
+    record_header_fullness.ool_stats.filled_bytes += ool_stats.header_raw_bytes;
+    record_header_fullness.ool_stats.total_bytes += ool_stats.header_bytes;
+
     if (t.get_src() == Transaction::src_t::CLEANER) {
       // CLEANER transaction won't contain any onode tree operations
       assert(t.onode_tree_stats.is_clear());
@@ -941,11 +992,20 @@ record_t Cache::prepare_record(Transaction &t)
   ceph_assert(ool_stats.extents.num == t.ool_block_list.size());
   efforts.num_ool_records += ool_stats.num_records;
   efforts.ool_record_overhead_bytes += ool_stats.header_bytes;
+
+  auto& record_header_fullness = get_by_src(
+      stats.record_header_fullness_by_src, t.get_src());
+  record_header_fullness.ool_stats.filled_bytes += ool_stats.header_raw_bytes;
+  record_header_fullness.ool_stats.total_bytes += ool_stats.header_bytes;
+
   auto record_size = get_encoded_record_length(
       record, segment_manager.get_block_size());
   auto inline_overhead =
       record_size.mdlength + record_size.dlength - record.get_raw_data_size();
   efforts.inline_record_overhead_bytes += inline_overhead;
+  record_header_fullness.inline_stats.filled_bytes += record_size.raw_mdlength;
+  record_header_fullness.inline_stats.total_bytes += record_size.mdlength;
+
   return record;
 }
 
index f1449adb22119682ff1494a79d460676d9e8e3fc..b05d25e4f4fc7d515336f2233182400b3674664c 100644 (file)
@@ -697,11 +697,22 @@ private:
   template <typename CounterT>
   using counter_by_src_t = std::array<CounterT, Transaction::SRC_MAX>;
 
+  struct fill_stat_t {
+    uint64_t filled_bytes = 0;
+    uint64_t total_bytes = 0;
+  };
+
+  struct record_header_fullness_t {
+    fill_stat_t inline_stats;
+    fill_stat_t ool_stats;
+  };
+
   struct {
     counter_by_src_t<uint64_t> trans_created_by_src;
     counter_by_src_t<commit_trans_efforts_t> committed_efforts_by_src;
     counter_by_src_t<invalid_trans_efforts_t> invalidated_efforts_by_src;
     counter_by_src_t<query_counters_t> cache_query_by_src;
+    counter_by_src_t<record_header_fullness_t> record_header_fullness_by_src;
     success_read_trans_efforts_t success_read_efforts;
     uint64_t dirty_bytes = 0;
 
index 4ed38a078a7c7ff499b611d08b3838cd1e694890..48a89ea273ae93ff6f5858c4582d03f99938997d 100644 (file)
@@ -92,6 +92,7 @@ SegmentedAllocator::Writer::_write(
   auto& stats = t.get_ool_write_stats();
   stats.extents.num += record.get_num_extents();
   stats.extents.bytes += record_size.dlength;
+  stats.header_raw_bytes += record_size.raw_mdlength;
   stats.header_bytes += record_size.mdlength;
   stats.num_records += 1;
 
index 866798279608a95ab149ffb306a7cffaeac8d921..4dec28783988b69bba843c45128ebf70bc86561f 100644 (file)
@@ -137,7 +137,7 @@ record_size_t get_encoded_record_length(
   for (const auto &i: record.extents) {
     dlength += i.bl.length();
   }
-  return record_size_t{mdlength, dlength};
+  return record_size_t{raw_mdlength, mdlength, dlength};
 }
 
 ceph::bufferlist encode_record(
@@ -172,6 +172,8 @@ ceph::bufferlist encode_record(
   for (const auto &i: record.deltas) {
     encode(i, bl);
   }
+  ceph_assert(bl.length() == rsize.raw_mdlength);
+
   if (bl.length() % block_size != 0) {
     bl.append_zero(
       block_size - (bl.length() % block_size));
index e4e5b77850376823b42d5835ad065f4dc72658db..b2c70a574a6771dca4193be34910a9438929abf8 100644 (file)
@@ -836,6 +836,7 @@ struct record_header_t {
 std::ostream &operator<<(std::ostream &out, const extent_info_t &header);
 
 struct record_size_t {
+  extent_len_t raw_mdlength = 0;
   extent_len_t mdlength = 0;
   extent_len_t dlength = 0;
 };
index f1d2e1a52f650a95dde41eae0a6d93f2abcc8af8..4d406db99f989de77d7015be433f79d53a8f4607 100644 (file)
@@ -302,6 +302,7 @@ public:
 
   struct ool_write_stats_t {
     io_stat_t extents;
+    uint64_t header_raw_bytes = 0;
     uint64_t header_bytes = 0;
     uint64_t num_records = 0;
   };