Skip to content

Commit 177ff7a

Browse files
committed
os/bluestore: Add "bluestore compression stats"
Add new admin socket command to inspect Estimator stats per collection. Signed-off-by: Adam Kupczyk <[email protected]>
1 parent 86bd353 commit 177ff7a

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

src/os/bluestore/BlueAdmin.cc

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

44
#include "BlueAdmin.h"
5+
#include "Compression.h"
56
#include "common/pretty_binary.h"
67
#include "common/debug.h"
78
#include <asm-generic/errno-base.h>
@@ -42,6 +43,12 @@ BlueStore::SocketHook::SocketHook(BlueStore& store)
4243
this,
4344
"print object internals");
4445
ceph_assert(r == 0);
46+
r = admin_socket->register_command(
47+
"bluestore compression stats "
48+
"name=collection,type=CephString,req=false",
49+
this,
50+
"print compression stats, per collection");
51+
ceph_assert(r == 0);
4552
}
4653
}
4754

@@ -142,6 +149,34 @@ int BlueStore::SocketHook::call(
142149
}
143150
r = -ENOENT;
144151
ss << "No collection that can hold such object" << std::endl;
152+
} else if (command == "bluestore compression stats") {
153+
std::vector<CollectionRef> copied;
154+
{
155+
std::shared_lock l(store.coll_lock);
156+
copied.reserve(store.coll_map.size());
157+
for (const auto& c : store.coll_map) {
158+
copied.push_back(c.second);
159+
}
160+
}
161+
std::string coll;
162+
cmd_getval(cmdmap, "collection", coll);
163+
f->open_array_section("compression");
164+
for (const auto& c : copied) {
165+
std::shared_lock l(c->lock);
166+
if ((coll.empty() && bool(c->estimator))
167+
|| coll == c->get_cid().c_str()) {
168+
f->open_object_section("collection");
169+
f->dump_string("cid", c->get_cid().c_str());
170+
f->open_object_section("estimator");
171+
if (c->estimator) {
172+
c->estimator->dump(f);
173+
}
174+
f->close_section();
175+
f->close_section();
176+
}
177+
}
178+
f->close_section();
179+
return 0;
145180
} else {
146181
ss << "Invalid command" << std::endl;
147182
r = -ENOSYS;

src/os/bluestore/Compression.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ void Estimator::finish()
223223
cleanup();
224224
}
225225

226+
void Estimator::dump(Formatter *f) const {
227+
f->dump_float("expected_compression_now", expected_compression_factor);
228+
f->dump_float("expected_recompression_error", expected_recompression_error);
229+
f->dump_float("expected_pad_expansion", expected_pad_expansion);
230+
}
231+
226232
Estimator* BlueStore::create_estimator()
227233
{
228234
return new Estimator(this);

src/os/bluestore/Compression.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class BlueStore::Estimator {
5151
Writer::blob_vec& bd);
5252

5353
void finish();
54-
54+
void dump(Formatter *f) const;
5555
private:
5656
BlueStore* bluestore;
5757
double expected_compression_factor = 0.5;

0 commit comments

Comments
 (0)