]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common/Finisher: un-inline ctor and dtor
authorMax Kellermann <max.kellermann@ionos.com>
Wed, 9 Oct 2024 12:19:13 +0000 (14:19 +0200)
committerMax Kellermann <max.kellermann@ionos.com>
Thu, 10 Oct 2024 05:32:57 +0000 (07:32 +0200)
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 <max.kellermann@ionos.com>
src/common/Finisher.cc
src/common/Finisher.h

index 8f2262235e89bb6172e00319610a7c74304a4c29..5f0557306ce35608122afa438999c1f63205bb8f 100644 (file)
@@ -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;
index 28c519b409c82bb4b67400fd851047d4651bbb43..c5c16052ff7c8e68883f26f069cd2eef5a3705b0 100644 (file)
@@ -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.