]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: compact trimmed range, not entire prefix
authorSage Weil <sage@inktank.com>
Wed, 29 May 2013 15:40:32 +0000 (08:40 -0700)
committerSage Weil <sage@inktank.com>
Wed, 29 May 2013 15:40:32 +0000 (08:40 -0700)
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>
src/mon/Paxos.cc
src/mon/PaxosService.cc

index 71ef2ec3de035b3edf2f4b6331f8e75c0773965a..f68afac9948c77ba07b598c46cd4c9207351adaf 100644 (file)
@@ -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
@@ -970,14 +971,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));
   }
 }
 
index 719ba48a65cfd1aa89d817bc6a19d9c47ac8fead..fd9c6ad540ae9e43cbbd6c5aa74e797714dda870 100644 (file)
@@ -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));
   }
 }