summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max.kellermann@ionos.com>2024-10-09 14:19:13 +0200
committerMax Kellermann <max.kellermann@ionos.com>2024-10-10 07:32:57 +0200
commit3717827b8bcb2f4ab5859575a95785020c291c12 (patch)
tree882dd58a78826a2a67b048363dcc40015db050cf
parentcommon/Finisher: add `const` to several fields (diff)
downloadceph-3717827b8bcb2f4ab5859575a95785020c291c12.tar.xz
ceph-3717827b8bcb2f4ab5859575a95785020c291c12.zip
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 <max.kellermann@ionos.com>
-rw-r--r--src/common/Finisher.cc27
-rw-r--r--src/common/Finisher.h28
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.