From 3717827b8bcb2f4ab5859575a95785020c291c12 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 9 Oct 2024 14:19:13 +0200 Subject: common/Finisher: un-inline ctor and dtor This aims to speed up compile times because constructor and destructor contain a lot of code that would be compiled in sources that do not call them. Also this allows removing the "common/perf_counters.h" include. Since there is now only one instantiation of these for all call sites, the binary size shrinks by nearly 1 kB. Signed-off-by: Max Kellermann --- src/common/Finisher.cc | 27 +++++++++++++++++++++++++++ src/common/Finisher.h | 28 +++------------------------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/common/Finisher.cc b/src/common/Finisher.cc index 8f2262235e8..5f0557306ce 100644 --- a/src/common/Finisher.cc +++ b/src/common/Finisher.cc @@ -2,11 +2,38 @@ // vim: ts=8 sw=2 smarttab #include "Finisher.h" +#include "common/perf_counters.h" #define dout_subsys ceph_subsys_finisher #undef dout_prefix #define dout_prefix *_dout << "finisher(" << this << ") " +Finisher::Finisher(CephContext *cct_) : + cct(cct_), finisher_lock(ceph::make_mutex("Finisher::finisher_lock")), + thread_name("fn_anonymous"), + finisher_thread(this) {} + +Finisher::Finisher(CephContext *cct_, std::string name, std::string tn) : + cct(cct_), finisher_lock(ceph::make_mutex("Finisher::" + name)), + thread_name(tn), + finisher_thread(this) { + PerfCountersBuilder b(cct, std::string("finisher-") + name, + l_finisher_first, l_finisher_last); + b.add_u64(l_finisher_queue_len, "queue_len"); + b.add_time_avg(l_finisher_complete_lat, "complete_latency"); + logger = b.create_perf_counters(); + cct->get_perfcounters_collection()->add(logger); + logger->set(l_finisher_queue_len, 0); + logger->set(l_finisher_complete_lat, 0); +} + +Finisher::~Finisher() { + if (logger && cct) { + cct->get_perfcounters_collection()->remove(logger); + delete logger; + } +} + void Finisher::start() { ldout(cct, 10) << __func__ << dendl; diff --git a/src/common/Finisher.h b/src/common/Finisher.h index 28c519b409c..c5c16052ff7 100644 --- a/src/common/Finisher.h +++ b/src/common/Finisher.h @@ -19,7 +19,6 @@ #include "include/common_fwd.h" #include "common/Thread.h" #include "common/ceph_mutex.h" -#include "common/perf_counters.h" #include "common/Cond.h" /// Finisher queue length performance counter ID. @@ -116,32 +115,11 @@ class Finisher { /// Construct an anonymous Finisher. /// Anonymous finishers do not log their queue length. - explicit Finisher(CephContext *cct_) : - cct(cct_), finisher_lock(ceph::make_mutex("Finisher::finisher_lock")), - thread_name("fn_anonymous"), - finisher_thread(this) {} + explicit Finisher(CephContext *cct_); /// Construct a named Finisher that logs its queue length. - Finisher(CephContext *cct_, std::string name, std::string tn) : - cct(cct_), finisher_lock(ceph::make_mutex("Finisher::" + name)), - thread_name(tn), - finisher_thread(this) { - PerfCountersBuilder b(cct, std::string("finisher-") + name, - l_finisher_first, l_finisher_last); - b.add_u64(l_finisher_queue_len, "queue_len"); - b.add_time_avg(l_finisher_complete_lat, "complete_latency"); - logger = b.create_perf_counters(); - cct->get_perfcounters_collection()->add(logger); - logger->set(l_finisher_queue_len, 0); - logger->set(l_finisher_complete_lat, 0); - } - - ~Finisher() { - if (logger && cct) { - cct->get_perfcounters_collection()->remove(logger); - delete logger; - } - } + Finisher(CephContext *cct_, std::string name, std::string tn); + ~Finisher(); }; /// Context that is completed asynchronously on the supplied finisher. -- cgit v1.2.3