summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2013-05-29 08:40:32 -0700
committerSage Weil <sage@inktank.com>2013-06-02 14:09:51 -0700
commitd14665e550d9b2dfc47684b73427042b0744127f (patch)
tree84fd8d86912e4bba2bca36a48aa24ea1767bf457
parentdcd9b793fb0b05976b55be029315114d6f1df0e5 (diff)
downloadceph-d14665e550d9b2dfc47684b73427042b0744127f.tar.gz
mon: compact trimmed range, not entire prefix
This will reduce the work that leveldb is asked to do by only triggering compaction of the keys that were just trimmed. We ma want to further reduce the work by compacting less frequently, but this is at least a step in that direction. Signed-off-by: Sage Weil <sage@inktank.com> (cherry picked from commit 6da4b20ca53fc8161485c8a99a6b333e23ace30e)
-rw-r--r--src/mon/Paxos.cc12
-rw-r--r--src/mon/PaxosService.cc11
2 files changed, 12 insertions, 11 deletions
diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc
index bfb9ed4f5dd..7ff5edbd0a9 100644
--- a/src/mon/Paxos.cc
+++ b/src/mon/Paxos.cc
@@ -21,6 +21,7 @@
#include "common/config.h"
#include "include/assert.h"
+#include "include/stringify.h"
#include "common/Formatter.h"
#define dout_subsys ceph_subsys_paxos
@@ -959,14 +960,13 @@ void Paxos::trim_to(MonitorDBStore::Transaction *t,
dout(10) << __func__ << " from " << from << " to " << to << dendl;
assert(from < to);
- while (from < to) {
- dout(10) << "trim " << from << dendl;
- t->erase(get_name(), from);
- from++;
+ for (version_t v = from; v < to; ++v) {
+ dout(10) << "trim " << v << dendl;
+ t->erase(get_name(), v);
}
if (g_conf->mon_compact_on_trim) {
- dout(10) << " compacting prefix" << dendl;
- t->compact_prefix(get_name());
+ dout(10) << " compacting trimmed range" << dendl;
+ t->compact_range(get_name(), stringify(from), stringify(to));
}
}
diff --git a/src/mon/PaxosService.cc b/src/mon/PaxosService.cc
index 8f421ab3d81..3402cf7e76f 100644
--- a/src/mon/PaxosService.cc
+++ b/src/mon/PaxosService.cc
@@ -314,11 +314,12 @@ void PaxosService::trim(MonitorDBStore::Transaction *t,
{
dout(10) << __func__ << " from " << from << " to " << to << dendl;
assert(from != to);
- for (; from < to; from++) {
- dout(20) << __func__ << " " << from << dendl;
- t->erase(get_service_name(), from);
- string full_key = mon->store->combine_strings("full", from);
+ for (version_t v = from; v < to; ++v) {
+ dout(20) << __func__ << " " << v << dendl;
+ t->erase(get_service_name(), v);
+
+ string full_key = mon->store->combine_strings("full", v);
if (mon->store->exists(get_service_name(), full_key)) {
dout(20) << __func__ << " " << full_key << dendl;
t->erase(get_service_name(), full_key);
@@ -326,7 +327,7 @@ void PaxosService::trim(MonitorDBStore::Transaction *t,
}
if (g_conf->mon_compact_on_trim) {
dout(20) << " compacting prefix " << get_service_name() << dendl;
- t->compact_prefix(get_service_name());
+ t->compact_range(get_service_name(), stringify(from), stringify(to));
}
}