From: Sage Weil Date: Wed, 29 May 2013 15:40:32 +0000 (-0700) Subject: mon: compact trimmed range, not entire prefix X-Git-Tag: v0.64~35^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6da4b20ca53fc8161485c8a99a6b333e23ace30e;p=ceph.git 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 --- diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc index 71ef2ec3de03..f68afac9948c 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 @@ -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)); } } diff --git a/src/mon/PaxosService.cc b/src/mon/PaxosService.cc index 719ba48a65cf..fd9c6ad540ae 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)); } }