From: Mykola Golub Date: Sun, 23 Sep 2018 17:33:14 +0000 (+0300) Subject: osd: collect client perf stats when query is enabled X-Git-Tag: v14.1.0~945^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f495b8cce9014d3459f41691ad5eb7ca1fc9d153;p=ceph.git osd: collect client perf stats when query is enabled Fixes: https://tracker.ceph.com/issues/36091 Signed-off-by: Mykola Golub --- diff --git a/src/messages/MMgrConfigure.h b/src/messages/MMgrConfigure.h index e0e7008078c0..e53a357ff2b2 100644 --- a/src/messages/MMgrConfigure.h +++ b/src/messages/MMgrConfigure.h @@ -16,7 +16,7 @@ #define CEPH_MMGRCONFIGURE_H_ #include "msg/Message.h" -#include "mgr/OSDPerfMetricQuery.h" +#include "mgr/OSDPerfMetricTypes.h" /** * This message is sent from ceph-mgr to MgrClient, instructing it diff --git a/src/messages/MMgrReport.h b/src/messages/MMgrReport.h index 1fbcdcd04ec7..82d1bd89e97d 100644 --- a/src/messages/MMgrReport.h +++ b/src/messages/MMgrReport.h @@ -18,7 +18,7 @@ #include #include "msg/Message.h" -#include "mgr/OSDPerfMetricReport.h" +#include "mgr/OSDPerfMetricTypes.h" #include "common/perf_counters.h" #include "mgr/DaemonHealthMetric.h" @@ -107,7 +107,7 @@ public: // encode map> of current config bufferlist config_bl; - std::list osd_perf_metric_reports; + std::map osd_perf_metric_reports; void decode_payload() override { diff --git a/src/mgr/ActivePyModules.h b/src/mgr/ActivePyModules.h index 16f781e03a75..ae834039717d 100644 --- a/src/mgr/ActivePyModules.h +++ b/src/mgr/ActivePyModules.h @@ -28,11 +28,10 @@ #include "DaemonState.h" #include "ClusterState.h" -#include "OSDPerfMetricQuery.h" +#include "OSDPerfMetricTypes.h" class health_check_map_t; class DaemonServer; -struct OSDPerfMetricQuery; class ActivePyModules { diff --git a/src/mgr/CMakeLists.txt b/src/mgr/CMakeLists.txt index f7fb4f9cb5a0..f8b12747c603 100644 --- a/src/mgr/CMakeLists.txt +++ b/src/mgr/CMakeLists.txt @@ -12,7 +12,7 @@ set(mgr_srcs Gil.cc Mgr.cc MgrStandby.cc - OSDPerfMetricQuery.cc + OSDPerfMetricTypes.cc OSDPerfMetricCollector.cc PyFormatter.cc PyModule.cc diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index 99ed41d7b0c4..0abc48ac4135 100644 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@ -639,6 +639,10 @@ bool DaemonServer::handle_report(MMgrReport *m) py_modules.notify_all("perf_schema_update", oss.str()); } + if (m->get_connection()->peer_is_osd()) { + osd_perf_metric_collector.process_reports(m->osd_perf_metric_reports); + } + m->put(); return true; } diff --git a/src/mgr/MgrClient.cc b/src/mgr/MgrClient.cc index 4bddbe2a19ce..db5b586127b3 100644 --- a/src/mgr/MgrClient.cc +++ b/src/mgr/MgrClient.cc @@ -351,7 +351,7 @@ void MgrClient::_send_report() &last_config_bl_version); if (get_perf_report_cb) { - //get_perf_report_cb(&report->perf_report) + get_perf_report_cb(&report->osd_perf_metric_reports); } session->con->send_message(report); @@ -389,16 +389,16 @@ bool MgrClient::handle_mgr_configure(MMgrConfigure *m) stats_threshold = m->stats_threshold; } + if (set_perf_queries_cb) { + set_perf_queries_cb(m->osd_perf_metric_queries); + } + bool starting = (stats_period == 0) && (m->stats_period != 0); stats_period = m->stats_period; if (starting) { _send_stats(); } - if (set_perf_queries_cb) { - set_perf_queries_cb(m->osd_perf_metric_queries); - } - m->put(); return true; } diff --git a/src/mgr/MgrClient.h b/src/mgr/MgrClient.h index 5b561d26170d..72348ab23c53 100644 --- a/src/mgr/MgrClient.h +++ b/src/mgr/MgrClient.h @@ -20,14 +20,12 @@ #include "mgr/DaemonHealthMetric.h" #include "messages/MMgrReport.h" -#include "mgr/OSDPerfMetricQuery.h" +#include "mgr/OSDPerfMetricTypes.h" #include "common/perf_counters.h" #include "common/Timer.h" #include "common/CommandTable.h" -typedef int OSDPerfMetricReport; //Temporary - class MMgrMap; class MMgrConfigure; class MMgrClose; @@ -82,7 +80,8 @@ protected: // our reports (hook for use by OSD) std::function pgstats_cb; std::function &)> set_perf_queries_cb; - std::function get_perf_report_cb; + std::function *)> get_perf_report_cb; // for service registration and beacon bool service_daemon = false; @@ -121,15 +120,14 @@ public: void set_perf_metric_query_cb( std::function &)> cb_set, - std::function cb_get) - + std::function *)> cb_get) { std::lock_guard l(lock); set_perf_queries_cb = cb_set; get_perf_report_cb = cb_get; } - void send_pgstats(); void set_pgstats_cb(std::function&& cb_) { diff --git a/src/mgr/OSDPerfMetricCollector.cc b/src/mgr/OSDPerfMetricCollector.cc index 6c4354d7abed..1d922d16ed78 100644 --- a/src/mgr/OSDPerfMetricCollector.cc +++ b/src/mgr/OSDPerfMetricCollector.cc @@ -102,3 +102,29 @@ void OSDPerfMetricCollector::remove_all_queries() { listener.handle_query_updated(); } } + +void OSDPerfMetricCollector::process_reports( + const std::map &reports) { + + if (reports.empty()) { + return; + } + + std::lock_guard locker(lock); + + for (auto &it : reports) { + auto &report = it.second; + dout(10) << "report for " << it.first << " query: " + << report.group_packed_performance_counters.size() << " records" + << dendl; + for (auto &it : report.group_packed_performance_counters) { + auto &key = it.first; + auto bl_it = it.second.cbegin(); + for (auto &d : report.performance_counter_descriptors) { + PerformanceCounter c; + d.unpack_counter(bl_it, &c); + dout(20) << "counter " << key << " " << d << ": " << c << dendl; + } + } + } +} diff --git a/src/mgr/OSDPerfMetricCollector.h b/src/mgr/OSDPerfMetricCollector.h index 8035da46fa08..ca32df35ff29 100644 --- a/src/mgr/OSDPerfMetricCollector.h +++ b/src/mgr/OSDPerfMetricCollector.h @@ -6,7 +6,7 @@ #include "common/Mutex.h" -#include "mgr/OSDPerfMetricQuery.h" +#include "mgr/OSDPerfMetricTypes.h" #include #include @@ -31,6 +31,9 @@ public: int remove_query(OSDPerfMetricQueryID query_id); void remove_all_queries(); + void process_reports( + const std::map &reports); + private: typedef std::map> Queries; diff --git a/src/mgr/OSDPerfMetricQuery.cc b/src/mgr/OSDPerfMetricQuery.cc deleted file mode 100644 index 9b13f69e122e..000000000000 --- a/src/mgr/OSDPerfMetricQuery.cc +++ /dev/null @@ -1,8 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab - -#include "OSDPerfMetricQuery.h" - -std::ostream& operator<<(std::ostream& os, const OSDPerfMetricQuery &query) { - return os << "simple"; -} diff --git a/src/mgr/OSDPerfMetricQuery.h b/src/mgr/OSDPerfMetricQuery.h deleted file mode 100644 index 708297204897..000000000000 --- a/src/mgr/OSDPerfMetricQuery.h +++ /dev/null @@ -1,26 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab - -#ifndef OSD_PERF_METRIC_QUERY_H_ -#define OSD_PERF_METRIC_QUERY_H_ - -#include "include/denc.h" - -typedef int OSDPerfMetricQueryID; - -struct OSDPerfMetricQuery -{ - bool operator<(const OSDPerfMetricQuery &other) const { - return false; - } - - DENC(OSDPerfMetricQuery, v, p) { - DENC_START(1, 1, p); - DENC_FINISH(p); - } -}; -WRITE_CLASS_DENC(OSDPerfMetricQuery) - -std::ostream& operator<<(std::ostream& os, const OSDPerfMetricQuery &query); - -#endif // OSD_PERF_METRIC_QUERY_H_ diff --git a/src/mgr/OSDPerfMetricReport.h b/src/mgr/OSDPerfMetricReport.h deleted file mode 100644 index 8868c4b889b1..000000000000 --- a/src/mgr/OSDPerfMetricReport.h +++ /dev/null @@ -1,27 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab -#ifndef OSD_PERF_METRIC_REPORT_H_ -#define OSD_PERF_METRIC_REPORT_H_ -#include "include/denc.h" - -#include "common/perf_counters.h" - -struct PerformanceCounterDescriptor { - std::string name; - perfcounter_type_d type; -}; - - -struct OSDPerfMetricReport { - std::vector performance_counter_descriptors; - std::map group_packed_performance_counters; - - DENC(OSDPerfMetricReport, v, p) { - DENC_START(1, 1, p); -// denc(v.performance_counter_descriptors, p); - DENC_FINISH(p); - } -}; -WRITE_CLASS_DENC(OSDPerfMetricReport) - -#endif // OSD_PERF_METRIC_REPORT_H_ diff --git a/src/mgr/OSDPerfMetricTypes.cc b/src/mgr/OSDPerfMetricTypes.cc new file mode 100644 index 000000000000..2177bed37a0a --- /dev/null +++ b/src/mgr/OSDPerfMetricTypes.cc @@ -0,0 +1,148 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#include "mgr/OSDPerfMetricTypes.h" +#include "messages/MOSDOp.h" +#include "osd/OpRequest.h" + +void PerformanceCounterDescriptor::update_counter( + const OpRequest& op, uint64_t inb, uint64_t outb, const utime_t &now, + PerformanceCounter *c) const { + switch(type) { + case PerformanceCounterType::WRITE_OPS: + if (op.may_write() || op.may_cache()) { + c->first++; + } + return; + case PerformanceCounterType::READ_OPS: + if (op.may_read()) { + c->first++; + } + return; + case PerformanceCounterType::WRITE_BYTES: + if (op.may_write() || op.may_cache()) { + c->first += inb; + c->second++; + } + return; + case PerformanceCounterType::READ_BYTES: + if (op.may_read()) { + c->first += outb; + c->second++; + } + return; + case PerformanceCounterType::WRITE_LATENCY: + if (op.may_write() || op.may_cache()) { + const MOSDOp* const m = static_cast(op.get_req()); + c->first += (now - m->get_recv_stamp()).to_nsec(); + c->second++; + } + return; + case PerformanceCounterType::READ_LATENCY: + if (op.may_read()) { + const MOSDOp* const m = static_cast(op.get_req()); + c->first += (now - m->get_recv_stamp()).to_nsec(); + c->second++; + } + return; + default: + ceph_abort_msg("unknown counter type"); + } +} + +void PerformanceCounterDescriptor::pack_counter(const PerformanceCounter &c, + bufferlist *bl) const { + using ceph::encode; + encode(c.first, *bl); + switch(type) { + case PerformanceCounterType::WRITE_OPS: + case PerformanceCounterType::READ_OPS: + break; + case PerformanceCounterType::WRITE_BYTES: + case PerformanceCounterType::READ_BYTES: + case PerformanceCounterType::WRITE_LATENCY: + case PerformanceCounterType::READ_LATENCY: + encode(c.second, *bl); + break; + default: + ceph_abort_msg("unknown counter type"); + } +} + +void PerformanceCounterDescriptor::unpack_counter( + bufferlist::const_iterator& bl, PerformanceCounter *c) const { + using ceph::decode; + decode(c->first, bl); + switch(type) { + case PerformanceCounterType::WRITE_OPS: + case PerformanceCounterType::READ_OPS: + break; + case PerformanceCounterType::WRITE_BYTES: + case PerformanceCounterType::READ_BYTES: + case PerformanceCounterType::WRITE_LATENCY: + case PerformanceCounterType::READ_LATENCY: + decode(c->second, bl); + break; + default: + ceph_abort_msg("unknown counter type"); + } +} + +std::ostream& operator<<(std::ostream& os, + const PerformanceCounterDescriptor &d) { + switch(d.type) { + case PerformanceCounterType::WRITE_OPS: + return os << "write ops"; + case PerformanceCounterType::READ_OPS: + return os << "read ops"; + case PerformanceCounterType::WRITE_BYTES: + return os << "write bytes"; + case PerformanceCounterType::READ_BYTES: + return os << "read bytes"; + case PerformanceCounterType::WRITE_LATENCY: + return os << "write latency"; + case PerformanceCounterType::READ_LATENCY: + return os << "read latency"; + default: + return os << "unknown (" << d.type << ")"; + } +} + +bool OSDPerfMetricQuery::get_key(const OpRequest& op, std::string *key) const { + const MOSDOp* const m = static_cast(op.get_req()); + + *key = stringify(m->get_reqid().name); + return true; +} + +void OSDPerfMetricQuery::update_counters(const OpRequest& op, uint64_t inb, + uint64_t outb, const utime_t &now, + PerformanceCounters *counters) const { + auto it = counters->begin(); + for (auto &descriptor : performance_counter_descriptors) { + // TODO: optimize + if (it == counters->end()) { + counters->push_back(PerformanceCounter()); + it = std::prev(counters->end()); + } + descriptor.update_counter(op, inb, outb, now, &(*it)); + it++; + } +} + +void OSDPerfMetricQuery::pack_counters(const PerformanceCounters &counters, + bufferlist *bl) const { + auto it = counters.begin(); + for (auto &descriptor : performance_counter_descriptors) { + if (it == counters.end()) { + descriptor.pack_counter(PerformanceCounter(), bl); + } else { + descriptor.pack_counter(*it, bl); + it++; + } + } +} + +std::ostream& operator<<(std::ostream& os, const OSDPerfMetricQuery &query) { + return os << "simple"; +} diff --git a/src/mgr/OSDPerfMetricTypes.h b/src/mgr/OSDPerfMetricTypes.h new file mode 100644 index 000000000000..bd7cf0e50928 --- /dev/null +++ b/src/mgr/OSDPerfMetricTypes.h @@ -0,0 +1,104 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef OSD_PERF_METRIC_H_ +#define OSD_PERF_METRIC_H_ + +#include "include/denc.h" +#include "include/stringify.h" + +#include + +class OpRequest; +class utime_t; + +typedef std::pair PerformanceCounter; +typedef std::vector PerformanceCounters; + +enum class PerformanceCounterType : uint8_t { + WRITE_OPS = 0, + READ_OPS = 1, + WRITE_BYTES = 2, + READ_BYTES = 3, + WRITE_LATENCY = 4, + READ_LATENCY = 5, +}; + +struct PerformanceCounterDescriptor { + PerformanceCounterType type = static_cast(-1); + + PerformanceCounterDescriptor() { + } + + PerformanceCounterDescriptor(PerformanceCounterType type) : type(type) { + } + + DENC(PerformanceCounterDescriptor, v, p) { + DENC_START(1, 1, p); + denc(v.type, p); + DENC_FINISH(p); + } + + void update_counter(const OpRequest& op, uint64_t inb, uint64_t outb, + const utime_t &now, PerformanceCounter *c) const; + void pack_counter(const PerformanceCounter &c, bufferlist *bl) const; + void unpack_counter(bufferlist::const_iterator& bl, + PerformanceCounter *c) const; +}; +WRITE_CLASS_DENC(PerformanceCounterDescriptor) + +std::ostream& operator<<(std::ostream& os, + const PerformanceCounterDescriptor &d); + +typedef int OSDPerfMetricQueryID; + +struct OSDPerfMetricQuery { + bool operator<(const OSDPerfMetricQuery &other) const { + return false; + } + + bool get_key(const OpRequest& op, std::string *key) const; + + DENC(OSDPerfMetricQuery, v, p) { + DENC_START(1, 1, p); + denc(v.performance_counter_descriptors, p); + DENC_FINISH(p); + } + + void get_performance_counter_descriptors( + std::vector *descriptors) const { + *descriptors = performance_counter_descriptors; + } + + void update_counters(const OpRequest& op, uint64_t inb, uint64_t outb, + const utime_t &now, PerformanceCounters *counters) const; + void pack_counters(const PerformanceCounters &counters, bufferlist *bl) const; + + std::vector performance_counter_descriptors = { + {PerformanceCounterType::WRITE_OPS}, + {PerformanceCounterType::READ_OPS}, + {PerformanceCounterType::WRITE_BYTES}, + {PerformanceCounterType::READ_BYTES}, + {PerformanceCounterType::WRITE_LATENCY}, + {PerformanceCounterType::READ_LATENCY}, + }; +}; +WRITE_CLASS_DENC(OSDPerfMetricQuery) + +std::ostream& operator<<(std::ostream& os, const OSDPerfMetricQuery &query); + +struct OSDPerfMetricReport { + std::vector performance_counter_descriptors; + std::map group_packed_performance_counters; + + DENC(OSDPerfMetricReport, v, p) { + DENC_START(1, 1, p); + denc(v.performance_counter_descriptors, p); + denc(v.group_packed_performance_counters, p); + DENC_FINISH(p); + } +}; +WRITE_CLASS_DENC(OSDPerfMetricReport) + +#endif // OSD_PERF_METRIC_H_ + diff --git a/src/osd/CMakeLists.txt b/src/osd/CMakeLists.txt index 13b63bdce6b6..a1b16b598928 100644 --- a/src/osd/CMakeLists.txt +++ b/src/osd/CMakeLists.txt @@ -35,6 +35,7 @@ set(osd_srcs OpQueueItem.cc ${CMAKE_SOURCE_DIR}/src/common/TrackedOp.cc ${CMAKE_SOURCE_DIR}/src/objclass/class_api.cc + ${CMAKE_SOURCE_DIR}/src/mgr/OSDPerfMetricTypes.cc ${osd_cyg_functions_src} ${osdc_osd_srcs}) if(HAS_VTA) diff --git a/src/osd/DynamicPerfStats.h b/src/osd/DynamicPerfStats.h new file mode 100644 index 000000000000..dd19a858a088 --- /dev/null +++ b/src/osd/DynamicPerfStats.h @@ -0,0 +1,64 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef DYNAMIC_PERF_STATS_H +#define DYNAMIC_PERF_STATS_H + +#include "mgr/OSDPerfMetricTypes.h" + +class DynamicPerfStats { +public: + DynamicPerfStats() { + } + + DynamicPerfStats(const std::list &queries) { + for (auto &query : queries) { + data[query]; + } + } + + void set_queries(const std::list &queries) { + std::map> new_data; + for (auto &query : queries) { + std::swap(new_data[query], data[query]); + } + std::swap(data, new_data); + } + + bool is_enabled() { + return !data.empty(); + } + + void add(const OpRequest& op, uint64_t inb, uint64_t outb, + const utime_t &now) { + for (auto &it : data) { + auto &query = it.first; + std::string key; + if (query.get_key(op, &key)) { + query.update_counters(op, inb, outb, now, &it.second[key]); + } + } + } + + void add_to_reports( + std::map *reports) { + for (auto &it : data) { + auto &query = it.first; + auto &report = (*reports)[query]; + + query.get_performance_counter_descriptors( + &report.performance_counter_descriptors); + + for (auto &it_counters : it.second) { + auto &bl = report.group_packed_performance_counters[it_counters.first]; + query.pack_counters(it_counters.second, &bl); + } + } + } + +private: + std::map> data; +}; + +#endif // DYNAMIC_PERF_STATS_H diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 87c3ec84f516..aa60abfae033 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -2792,9 +2792,12 @@ int OSD::init() mgrc.set_pgstats_cb([this](){ return collect_pg_stats(); }); mgrc.set_perf_metric_query_cb( - [this](const std::list &queries){ set_perf_queries(queries);}, - [this](OSDPerfMetricReport *report){ get_perf_report(report); - }); + [this](const std::list &queries) { + set_perf_queries(queries); + }, + [this](std::map *reports) { + get_perf_reports(reports); + }); mgrc.init(); client_messenger->add_dispatcher_head(&mgrc); @@ -4246,6 +4249,11 @@ PGRef OSD::handle_pg_create_info(const OSDMapRef& osdmap, false, rctx.transaction); + if (pg->is_primary()) { + Mutex::Locker locker(m_perf_queries_lock); + pg->set_dynamic_perf_stats_queries(m_perf_queries); + } + pg->handle_initialize(&rctx); pg->handle_activate_map(&rctx); @@ -9760,9 +9768,38 @@ int OSD::init_op_flags(OpRequestRef& op) } void OSD::set_perf_queries(const std::list &queries) { + dout(10) << "setting " << queries.size() << " queries" << dendl; + + { + Mutex::Locker locker(m_perf_queries_lock); + m_perf_queries = queries; + } + + std::vector pgs; + _get_pgs(&pgs); + for (auto& pg : pgs) { + if (pg->is_primary()) { + pg->lock(); + pg->set_dynamic_perf_stats_queries(queries); + pg->unlock(); + } + } } -void OSD::get_perf_report(OSDPerfMetricReport *report) { +void OSD::get_perf_reports( + std::map *reports) { + std::vector pgs; + _get_pgs(&pgs); + DynamicPerfStats dps(m_perf_queries); + for (auto& pg : pgs) { + if (pg->is_primary()) { + pg->lock(); + pg->get_dynamic_perf_stats(&dps); + pg->unlock(); + } + } + dps.add_to_reports(reports); + dout(20) << "reports for " << reports->size() << " queries" << dendl; } // ============================================================= diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 4b6cf8edecd2..580536929b76 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -2315,7 +2315,11 @@ public: private: void set_perf_queries(const std::list &queries); - void get_perf_report(OSDPerfMetricReport *report); + void get_perf_reports( + std::map *reports); + + Mutex m_perf_queries_lock = {"OSD::m_perf_queries_lock"}; + std::list m_perf_queries; }; diff --git a/src/osd/PG.h b/src/osd/PG.h index 817801b7859e..9fe129ab04dc 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -45,6 +45,8 @@ #include "PGBackend.h" #include "PGPeeringEvent.h" +#include "mgr/OSDPerfMetricTypes.h" + #include #include #include @@ -69,6 +71,7 @@ struct OpRequest; typedef OpRequest::Ref OpRequestRef; class MOSDPGLog; class CephContext; +class DynamicPerfStats; namespace Scrub { class Store; @@ -482,6 +485,12 @@ public: void _delete_some(ObjectStore::Transaction *t); + virtual void set_dynamic_perf_stats_queries( + const std::list &queries) { + } + virtual void get_dynamic_perf_stats(DynamicPerfStats *stats) { + } + // reference counting #ifdef PG_DEBUG_REFS uint64_t get_with_id(); diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index bb0356713ee3..f26f4bdfd9f9 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -4139,6 +4139,21 @@ void PrimaryLogPG::log_op_stats(const OpRequest& op, << " inb " << inb << " outb " << outb << " lat " << latency << dendl; + + if (m_dynamic_perf_stats.is_enabled()) { + m_dynamic_perf_stats.add(op, inb, outb, latency); + } +} + +void PrimaryLogPG::set_dynamic_perf_stats_queries( + const std::list &queries) +{ + m_dynamic_perf_stats.set_queries(queries); +} + +void PrimaryLogPG::get_dynamic_perf_stats(DynamicPerfStats *stats) +{ + std::swap(m_dynamic_perf_stats, *stats); } void PrimaryLogPG::do_scan( diff --git a/src/osd/PrimaryLogPG.h b/src/osd/PrimaryLogPG.h index ad52529788b4..2eb333692933 100644 --- a/src/osd/PrimaryLogPG.h +++ b/src/osd/PrimaryLogPG.h @@ -19,6 +19,7 @@ #include #include "include/ceph_assert.h" +#include "DynamicPerfStats.h" #include "OSD.h" #include "PG.h" #include "Watch.h" @@ -1871,6 +1872,14 @@ public: int getattrs_maybe_cache( ObjectContextRef obc, map *out); + +public: + void set_dynamic_perf_stats_queries( + const std::list &queries) override; + void get_dynamic_perf_stats(DynamicPerfStats *stats) override; + +private: + DynamicPerfStats m_dynamic_perf_stats; }; inline ostream& operator<<(ostream& out, const PrimaryLogPG::RepGather& repop)