]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/journal/segment_allocator: fix metrics for RecordSubmitter
authorYingxin Cheng <yingxin.cheng@intel.com>
Thu, 17 Mar 2022 08:35:41 +0000 (16:35 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Fri, 18 Mar 2022 06:13:46 +0000 (14:13 +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/journal/segment_allocator.cc
src/crimson/os/seastore/journal/segment_allocator.h
src/crimson/os/seastore/journal/segmented_journal.cc
src/crimson/os/seastore/journal/segmented_journal.h
src/crimson/os/seastore/transaction.h

index ab73db01f389ac2d68a36b6f479bef3b3dcf1854..d0e6bfbd8dab58152a45e62193549aa542290892 100644 (file)
@@ -329,12 +329,6 @@ void Cache::register_metrics()
             sm::description("number of ool-records from committed transactions"),
             {src_label}
           ),
-          sm::make_counter(
-            "committed_ool_record_padding_bytes",
-            efforts.ool_record_padding_bytes,
-            sm::description("bytes of ool-record padding from committed transactions"),
-            {src_label}
-          ),
           sm::make_counter(
             "committed_ool_record_metadata_bytes",
             efforts.ool_record_metadata_bytes,
@@ -786,9 +780,8 @@ void Cache::mark_transaction_conflicted(
     auto& ool_stats = t.get_ool_write_stats();
     efforts.fresh_ool_written.increment_stat(ool_stats.extents);
     efforts.num_ool_records += ool_stats.num_records;
-    auto ool_record_bytes = (ool_stats.header_bytes + ool_stats.data_bytes);
+    auto ool_record_bytes = (ool_stats.md_bytes + ool_stats.get_data_bytes());
     efforts.ool_record_bytes += ool_record_bytes;
-    // Note: we only account overhead from committed ool records
 
     if (t.get_src() == Transaction::src_t::CLEANER_TRIM ||
         t.get_src() == Transaction::src_t::CLEANER_RECLAIM) {
@@ -1114,7 +1107,7 @@ record_t Cache::prepare_record(Transaction &t)
 
   SUBDEBUGT(seastore_t,
       "commit H{} dirty_from={}, {} read, {} fresh with {} invalid, "
-      "{} delta, {} retire, {}(md={}B, data={}B, fill={}) ool-records, "
+      "{} delta, {} retire, {}(md={}B, data={}B) ool-records, "
       "{}B md, {}B data",
       t, (void*)&t.get_handle(),
       get_oldest_dirty_from().value_or(JOURNAL_SEQ_NULL),
@@ -1124,10 +1117,8 @@ record_t Cache::prepare_record(Transaction &t)
       delta_stat,
       retire_stat,
       ool_stats.num_records,
-      ool_stats.header_raw_bytes,
-      ool_stats.data_bytes,
-      ((double)(ool_stats.header_raw_bytes + ool_stats.data_bytes) /
-       (ool_stats.header_bytes + ool_stats.data_bytes)),
+      ool_stats.md_bytes,
+      ool_stats.get_data_bytes(),
       record.size.get_raw_mdlength(),
       record.size.dlength);
   if (trans_src == Transaction::src_t::CLEANER_TRIM ||
@@ -1150,10 +1141,8 @@ record_t Cache::prepare_record(Transaction &t)
 
   ++(efforts.num_trans);
   efforts.num_ool_records += ool_stats.num_records;
-  efforts.ool_record_padding_bytes +=
-    (ool_stats.header_bytes - ool_stats.header_raw_bytes);
-  efforts.ool_record_metadata_bytes += ool_stats.header_raw_bytes;
-  efforts.ool_record_data_bytes += ool_stats.data_bytes;
+  efforts.ool_record_metadata_bytes += ool_stats.md_bytes;
+  efforts.ool_record_data_bytes += ool_stats.get_data_bytes();
   efforts.inline_record_metadata_bytes +=
     (record.size.get_raw_mdlength() - record.get_delta_size());
 
index cc9c53d783ca729c33c2d74eb3beb917ffc875b5..a335a6b22c3cbbe884ca3a6e27ef72c6609f2f9a 100644 (file)
@@ -873,7 +873,6 @@ private:
     counter_by_extent_t<io_stat_t> fresh_ool_by_ext;
     uint64_t num_trans = 0; // the number of inline records
     uint64_t num_ool_records = 0;
-    uint64_t ool_record_padding_bytes = 0;
     uint64_t ool_record_metadata_bytes = 0;
     uint64_t ool_record_data_bytes = 0;
     uint64_t inline_record_metadata_bytes = 0; // metadata exclude the delta bytes
index 538d8cd9929d281a61386d5b7eb64f09b97757de..ed1c21d5657eab1744e69ae84f1ec217809e709a 100644 (file)
@@ -46,15 +46,10 @@ SegmentedAllocator::Writer::write_record(
   assert(!record.deltas.size());
 
   // account transactional ool writes before write()
-  // TODO: drop the incorrect size and fix the metrics
-  auto record_size = record_group_size_t(
-      record.size, segment_allocator.get_block_size());
   auto& stats = t.get_ool_write_stats();
   stats.extents.num += extents.size();
-  stats.extents.bytes += record_size.dlength;
-  stats.header_raw_bytes += record_size.get_raw_mdlength();
-  stats.header_bytes += record_size.get_mdlength();
-  stats.data_bytes += record_size.dlength;
+  stats.extents.bytes += record.size.dlength;
+  stats.md_bytes += record.size.get_raw_mdlength();
   stats.num_records += 1;
 
   return record_submitter.submit(std::move(record)
index 99b51752cdfb9df20622db3233d343c61b095f6f..9f3a16efbc038faf5f870af77565c630dc7ae0cf 100644 (file)
@@ -582,7 +582,63 @@ RecordSubmitter::submit(record_t&& record)
 RecordSubmitter::open_ret
 RecordSubmitter::open()
 {
-  return segment_allocator.open();
+  return segment_allocator.open(
+  ).safe_then([this](journal_seq_t ret) {
+    LOG_PREFIX(RecordSubmitter::open);
+    DEBUG("{} register metrics", get_name());
+    stats = {};
+    namespace sm = seastar::metrics;
+    std::vector<sm::label_instance> label_instances;
+    label_instances.push_back(sm::label_instance("submitter", get_name()));
+    metrics.add_group(
+      "journal",
+      {
+        sm::make_counter(
+          "record_num",
+          stats.record_batch_stats.num_io,
+          sm::description("total number of records submitted"),
+          label_instances
+        ),
+        sm::make_counter(
+          "record_batch_num",
+          stats.record_batch_stats.num_io_grouped,
+          sm::description("total number of records batched"),
+          label_instances
+        ),
+        sm::make_counter(
+          "io_num",
+          stats.io_depth_stats.num_io,
+          sm::description("total number of io submitted"),
+          label_instances
+        ),
+        sm::make_counter(
+          "io_depth_num",
+          stats.io_depth_stats.num_io_grouped,
+          sm::description("total number of io depth"),
+          label_instances
+        ),
+        sm::make_counter(
+          "record_group_padding_bytes",
+          stats.record_group_padding_bytes,
+          sm::description("bytes of metadata padding when write record groups"),
+          label_instances
+        ),
+        sm::make_counter(
+          "record_group_metadata_bytes",
+          stats.record_group_metadata_bytes,
+          sm::description("bytes of raw metadata when write record groups"),
+          label_instances
+        ),
+        sm::make_counter(
+          "record_group_data_bytes",
+          stats.record_group_data_bytes,
+          sm::description("bytes of data when write record groups"),
+          label_instances
+        ),
+      }
+    );
+    return ret;
+  });
 }
 
 RecordSubmitter::close_ertr::future<>
@@ -596,6 +652,7 @@ RecordSubmitter::close()
   assert(!wait_available_promise.has_value());
   has_io_error = false;
   assert(!wait_unfull_flush_promise.has_value());
+  metrics.clear();
   return segment_allocator.close();
 }
 
@@ -654,6 +711,7 @@ void RecordSubmitter::account_submission(
     (size.get_mdlength() - size.get_raw_mdlength());
   stats.record_group_metadata_bytes += size.get_raw_mdlength();
   stats.record_group_data_bytes += size.dlength;
+  stats.record_batch_stats.increment(num);
 }
 
 void RecordSubmitter::finish_submit_batch(
index c2ad13aa97022e642b2d31efc614f347a4bf4859..0b862c3cee1fea5b0e12b154d4b6aac92ccc79c7 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <optional>
 #include <seastar/core/circular_buffer.hh>
+#include <seastar/core/metrics.hh>
 #include <seastar/core/shared_future.hh>
 
 #include "include/buffer.h"
@@ -366,34 +367,10 @@ public:
     return segment_allocator.get_name();
   }
 
-  grouped_io_stats get_record_batch_stats() const {
-    return stats.record_batch_stats;
-  }
-
-  grouped_io_stats get_io_depth_stats() const {
-    return stats.io_depth_stats;
-  }
-
-  uint64_t get_record_group_padding_bytes() const {
-    return stats.record_group_padding_bytes;
-  }
-
-  uint64_t get_record_group_metadata_bytes() const {
-    return stats.record_group_metadata_bytes;
-  }
-
-  uint64_t get_record_group_data_bytes() const {
-    return stats.record_group_data_bytes;
-  }
-
   journal_seq_t get_committed_to() const {
     return committed_to;
   }
 
-  void reset_stats() {
-    stats = {};
-  }
-
   // whether is available to submit a record
   bool is_available() const;
 
@@ -490,6 +467,7 @@ private:
     uint64_t record_group_metadata_bytes = 0;
     uint64_t record_group_data_bytes = 0;
   } stats;
+  seastar::metrics::metric_group metrics;
 };
 
 }
index ce76d14c22f1abfb418f00afe99d22860aa8da0d..fd570531ffcdc3cee00358decd5e7621ba633ab5 100644 (file)
@@ -46,7 +46,6 @@ SegmentedJournal::SegmentedJournal(
                      journal_segment_allocator),
     scanner(scanner)
 {
-  register_metrics();
 }
 
 SegmentedJournal::open_for_write_ret SegmentedJournal::open_for_write()
@@ -59,7 +58,6 @@ SegmentedJournal::close_ertr::future<> SegmentedJournal::close()
   LOG_PREFIX(Journal::close);
   INFO("closing, committed_to={}",
        record_submitter.get_committed_to());
-  metrics.clear();
   return record_submitter.close();
 }
 
@@ -378,66 +376,4 @@ SegmentedJournal::submit_record(
   return do_submit_record(std::move(record), handle);
 }
 
-void SegmentedJournal::register_metrics()
-{
-  LOG_PREFIX(Journal::register_metrics);
-  DEBUG("");
-  record_submitter.reset_stats();
-  namespace sm = seastar::metrics;
-  metrics.add_group(
-    "journal",
-    {
-      sm::make_counter(
-        "record_num",
-        [this] {
-          return record_submitter.get_record_batch_stats().num_io;
-        },
-        sm::description("total number of records submitted")
-      ),
-      sm::make_counter(
-        "record_batch_num",
-        [this] {
-          return record_submitter.get_record_batch_stats().num_io_grouped;
-        },
-        sm::description("total number of records batched")
-      ),
-      sm::make_counter(
-        "io_num",
-        [this] {
-          return record_submitter.get_io_depth_stats().num_io;
-        },
-        sm::description("total number of io submitted")
-      ),
-      sm::make_counter(
-        "io_depth_num",
-        [this] {
-          return record_submitter.get_io_depth_stats().num_io_grouped;
-        },
-        sm::description("total number of io depth")
-      ),
-      sm::make_counter(
-        "record_group_padding_bytes",
-        [this] {
-          return record_submitter.get_record_group_padding_bytes();
-        },
-        sm::description("bytes of metadata padding when write record groups")
-      ),
-      sm::make_counter(
-        "record_group_metadata_bytes",
-        [this] {
-          return record_submitter.get_record_group_metadata_bytes();
-        },
-        sm::description("bytes of raw metadata when write record groups")
-      ),
-      sm::make_counter(
-        "record_group_data_bytes",
-        [this] {
-          return record_submitter.get_record_group_data_bytes();
-        },
-        sm::description("bytes of data when write record groups")
-      ),
-    }
-  );
-}
-
 }
index 1ab33dd9281c6c69e153eb054f63caf78fa41751..e699f330bfc892691fa3adf2f785dac2abb424ab 100644 (file)
@@ -4,7 +4,6 @@
 #pragma once
 
 #include <seastar/core/future.hh>
-#include <seastar/core/metrics.hh>
 
 #include "include/ceph_assert.h"
 #include "include/buffer.h"
@@ -57,7 +56,6 @@ private:
   SegmentAllocator journal_segment_allocator;
   RecordSubmitter record_submitter;
   ExtentReader& scanner;
-  seastar::metrics::metric_group metrics;
   WritePipeline* write_pipeline = nullptr;
 
   /// read journal segment headers from scanner
@@ -87,8 +85,6 @@ private:
     segment_header_t header,         ///< [in] segment header
     delta_handler_t &delta_handler   ///< [in] processes deltas in order
   );
-
-  void register_metrics();
 };
 
 }
index bfda01b9ac35d09b5fb5d47c087aad02ce3b0cd4..25ef0eae4c4959389efc71d08aac0d17713eb12c 100644 (file)
@@ -341,16 +341,16 @@ public:
 
   struct ool_write_stats_t {
     io_stat_t extents;
-    uint64_t header_raw_bytes = 0;
-    uint64_t header_bytes = 0;
-    uint64_t data_bytes = 0;
+    uint64_t md_bytes = 0;
     uint64_t num_records = 0;
 
+    uint64_t get_data_bytes() const {
+      return extents.bytes;
+    }
+
     bool is_clear() const {
       return (extents.is_clear() &&
-              header_raw_bytes == 0 &&
-              header_bytes == 0 &&
-              data_bytes == 0 &&
+              md_bytes == 0 &&
               num_records == 0);
     }
   };