From: Yingxin Cheng Date: Thu, 17 Mar 2022 08:35:41 +0000 (+0800) Subject: crimson/os/seastore/journal/segment_allocator: fix metrics for RecordSubmitter X-Git-Tag: v18.0.0~1193^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1892a8aa991f899d59c67ee732fce53d5a7a4e6f;p=ceph.git crimson/os/seastore/journal/segment_allocator: fix metrics for RecordSubmitter Signed-off-by: Yingxin Cheng --- diff --git a/src/crimson/os/seastore/cache.cc b/src/crimson/os/seastore/cache.cc index ab73db01f389..d0e6bfbd8dab 100644 --- a/src/crimson/os/seastore/cache.cc +++ b/src/crimson/os/seastore/cache.cc @@ -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()); diff --git a/src/crimson/os/seastore/cache.h b/src/crimson/os/seastore/cache.h index cc9c53d783ca..a335a6b22c3c 100644 --- a/src/crimson/os/seastore/cache.h +++ b/src/crimson/os/seastore/cache.h @@ -873,7 +873,6 @@ private: counter_by_extent_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 diff --git a/src/crimson/os/seastore/extent_placement_manager.cc b/src/crimson/os/seastore/extent_placement_manager.cc index 538d8cd9929d..ed1c21d5657e 100644 --- a/src/crimson/os/seastore/extent_placement_manager.cc +++ b/src/crimson/os/seastore/extent_placement_manager.cc @@ -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) diff --git a/src/crimson/os/seastore/journal/segment_allocator.cc b/src/crimson/os/seastore/journal/segment_allocator.cc index 99b51752cdfb..9f3a16efbc03 100644 --- a/src/crimson/os/seastore/journal/segment_allocator.cc +++ b/src/crimson/os/seastore/journal/segment_allocator.cc @@ -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 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( diff --git a/src/crimson/os/seastore/journal/segment_allocator.h b/src/crimson/os/seastore/journal/segment_allocator.h index c2ad13aa9702..0b862c3cee1f 100644 --- a/src/crimson/os/seastore/journal/segment_allocator.h +++ b/src/crimson/os/seastore/journal/segment_allocator.h @@ -5,6 +5,7 @@ #include #include +#include #include #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; }; } diff --git a/src/crimson/os/seastore/journal/segmented_journal.cc b/src/crimson/os/seastore/journal/segmented_journal.cc index ce76d14c22f1..fd570531ffcd 100644 --- a/src/crimson/os/seastore/journal/segmented_journal.cc +++ b/src/crimson/os/seastore/journal/segmented_journal.cc @@ -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") - ), - } - ); -} - } diff --git a/src/crimson/os/seastore/journal/segmented_journal.h b/src/crimson/os/seastore/journal/segmented_journal.h index 1ab33dd9281c..e699f330bfc8 100644 --- a/src/crimson/os/seastore/journal/segmented_journal.h +++ b/src/crimson/os/seastore/journal/segmented_journal.h @@ -4,7 +4,6 @@ #pragma once #include -#include #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(); }; } diff --git a/src/crimson/os/seastore/transaction.h b/src/crimson/os/seastore/transaction.h index bfda01b9ac35..25ef0eae4c49 100644 --- a/src/crimson/os/seastore/transaction.h +++ b/src/crimson/os/seastore/transaction.h @@ -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); } };