Skip to content

Commit 3717827

Browse files
committed
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>
1 parent a1e7ef6 commit 3717827

File tree

2 files changed

+30
-25
lines changed

2 files changed

+30
-25
lines changed

src/common/Finisher.cc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,38 @@
22
// vim: ts=8 sw=2 smarttab
33

44
#include "Finisher.h"
5+
#include "common/perf_counters.h"
56

67
#define dout_subsys ceph_subsys_finisher
78
#undef dout_prefix
89
#define dout_prefix *_dout << "finisher(" << this << ") "
910

11+
Finisher::Finisher(CephContext *cct_) :
12+
cct(cct_), finisher_lock(ceph::make_mutex("Finisher::finisher_lock")),
13+
thread_name("fn_anonymous"),
14+
finisher_thread(this) {}
15+
16+
Finisher::Finisher(CephContext *cct_, std::string name, std::string tn) :
17+
cct(cct_), finisher_lock(ceph::make_mutex("Finisher::" + name)),
18+
thread_name(tn),
19+
finisher_thread(this) {
20+
PerfCountersBuilder b(cct, std::string("finisher-") + name,
21+
l_finisher_first, l_finisher_last);
22+
b.add_u64(l_finisher_queue_len, "queue_len");
23+
b.add_time_avg(l_finisher_complete_lat, "complete_latency");
24+
logger = b.create_perf_counters();
25+
cct->get_perfcounters_collection()->add(logger);
26+
logger->set(l_finisher_queue_len, 0);
27+
logger->set(l_finisher_complete_lat, 0);
28+
}
29+
30+
Finisher::~Finisher() {
31+
if (logger && cct) {
32+
cct->get_perfcounters_collection()->remove(logger);
33+
delete logger;
34+
}
35+
}
36+
1037
void Finisher::start()
1138
{
1239
ldout(cct, 10) << __func__ << dendl;

src/common/Finisher.h

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "include/common_fwd.h"
2020
#include "common/Thread.h"
2121
#include "common/ceph_mutex.h"
22-
#include "common/perf_counters.h"
2322
#include "common/Cond.h"
2423

2524
/// Finisher queue length performance counter ID.
@@ -116,32 +115,11 @@ class Finisher {
116115

117116
/// Construct an anonymous Finisher.
118117
/// Anonymous finishers do not log their queue length.
119-
explicit Finisher(CephContext *cct_) :
120-
cct(cct_), finisher_lock(ceph::make_mutex("Finisher::finisher_lock")),
121-
thread_name("fn_anonymous"),
122-
finisher_thread(this) {}
118+
explicit Finisher(CephContext *cct_);
123119

124120
/// Construct a named Finisher that logs its queue length.
125-
Finisher(CephContext *cct_, std::string name, std::string tn) :
126-
cct(cct_), finisher_lock(ceph::make_mutex("Finisher::" + name)),
127-
thread_name(tn),
128-
finisher_thread(this) {
129-
PerfCountersBuilder b(cct, std::string("finisher-") + name,
130-
l_finisher_first, l_finisher_last);
131-
b.add_u64(l_finisher_queue_len, "queue_len");
132-
b.add_time_avg(l_finisher_complete_lat, "complete_latency");
133-
logger = b.create_perf_counters();
134-
cct->get_perfcounters_collection()->add(logger);
135-
logger->set(l_finisher_queue_len, 0);
136-
logger->set(l_finisher_complete_lat, 0);
137-
}
138-
139-
~Finisher() {
140-
if (logger && cct) {
141-
cct->get_perfcounters_collection()->remove(logger);
142-
delete logger;
143-
}
144-
}
121+
Finisher(CephContext *cct_, std::string name, std::string tn);
122+
~Finisher();
145123
};
146124

147125
/// Context that is completed asynchronously on the supplied finisher.

0 commit comments

Comments
 (0)