]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: PaxosService: fix trim criteria so to avoid constantly trimming 230/head
authorJoao Eduardo Luis <joao.luis@inktank.com>
Thu, 18 Apr 2013 15:45:07 +0000 (16:45 +0100)
committerJoao Eduardo Luis <joao.luis@inktank.com>
Thu, 18 Apr 2013 15:45:07 +0000 (16:45 +0100)
Say a service establishes it will only keep 500 versions once a given
condition X is true.  Now say that said condition X only becomes true
after said service committing some 800 versions.

Once we decide to trim, this service would trim all 300 surplus versions
in one go.  After that, each committed version would also trim the
previous version.

Trimming an unbounded number of versions is not a good practice
as it will generate bigger transactions (thus a greater workload on
leveldb) and therefore bigger messages too.

Constantly trimming versions implies more frequent accesses to leveldb,
and keeping around a couple more versions won't hurt us in any significant
way, so let us put off trimming unless we go over a predefined minimum.

This patch adds two new options:

 paxos service trim min - minimum amount of versions to trigger a trim
                          (default: 30, 0 disables it)
 paxos service trim max - maximum amount of versions to trim during a
                          single proposal
                          (default: 50, 0 disables it)

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
src/common/config_opts.h
src/mon/MDSMonitor.h
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h
src/mon/PaxosService.cc
src/mon/PaxosService.h

index 3a9cfd708272241ea9327cca81cbc673e56c91e8..a0a21ca5b1cbd2df69ff057f0450c7222785c9d0 100644 (file)
@@ -191,6 +191,8 @@ OPTION(paxos_propose_interval, OPT_DOUBLE, 1.0)  // gather updates for this long
 OPTION(paxos_min_wait, OPT_DOUBLE, 0.05)  // min time to gather updates for after period of inactivity
 OPTION(paxos_trim_tolerance, OPT_INT, 30) // number of extra proposals tolerated before trimming
 OPTION(paxos_trim_disabled_max_versions, OPT_INT, 100) // maximum amount of versions we shall allow passing by without trimming
+OPTION(paxos_service_trim_max, OPT_INT, 50) // maximum amount of versions to trim during a single proposal (0 disables it)
+OPTION(paxos_service_trim_min, OPT_INT, 30) // minimum amount of versions to trigger a trim (0 disables it)
 OPTION(clock_offset, OPT_DOUBLE, 0) // how much to offset the system clock in Clock.cc
 OPTION(auth_cluster_required, OPT_STR, "cephx")   // required of mon, mds, osd daemons
 OPTION(auth_service_required, OPT_STR, "cephx")   // required by daemons of clients
index 3b1fbf92e2d2832f8d40467b4d3533755de66936..bda8f53c4fadecea7d1a9c833cc493d69c60b017 100644 (file)
@@ -75,7 +75,7 @@ class MDSMonitor : public PaxosService {
   // we don't require full versions; don't encode any.
   virtual void encode_full(MonitorDBStore::Transaction *t) { }
 
-  bool should_trim() { return false; }
+  bool service_should_trim() { return false; }
   void encode_trim(MonitorDBStore::Transaction *t) { }
 
   void update_logger();
index 40103ec402f8188568c41ca75b17b88872316cf3..21eba6c83ecba4d1fea12df88766bdf528737e46 100644 (file)
@@ -536,7 +536,7 @@ void OSDMonitor::update_trim()
   }
 }
 
-bool OSDMonitor::should_trim()
+bool OSDMonitor::service_should_trim()
 {
   update_trim();
   return (get_trim_to() > 0);
index e9f72298eb65cc7f72782f763d55525ac253e1c1..036aed5ffd3729c9fe3cd5a9363418704346b781 100644 (file)
@@ -155,7 +155,7 @@ private:
   bool should_propose(double &delay);
 
   void update_trim();
-  bool should_trim();
+  bool service_should_trim();
 
   bool can_mark_down(int o);
   bool can_mark_up(int o);
index a66c5ec06122179654d02ae04248c624a8ed44e2..44d53c20723808afb860a6573d485d4610790fd1 100644 (file)
@@ -152,7 +152,6 @@ void PaxosService::propose_pending()
 
   if (should_trim()) {
     encode_trim(&t);
-    set_trim_to(0);
   }
 
   encode_pending(&t);
@@ -327,7 +326,19 @@ void PaxosService::encode_trim(MonitorDBStore::Transaction *t)
   if (first_committed >= trim_to)
     return;
 
-  trim(t, first_committed, trim_to);
-  put_first_committed(t, trim_to);
+  version_t trim_to_max = trim_to;
+  if ((g_conf->paxos_service_trim_max > 0)
+      && (trim_to - first_committed > (size_t)g_conf->paxos_service_trim_max)) {
+    trim_to_max = first_committed + g_conf->paxos_service_trim_max;
+  }
+
+  dout(10) << __func__ << " trimming versions " << first_committed
+           << " to " << trim_to_max << dendl;
+
+  trim(t, first_committed, trim_to_max);
+  put_first_committed(t, trim_to_max);
+
+  if (trim_to_max == trim_to)
+    set_trim_to(0);
 }
 
index f16bc77cdeb1b28d14a16e8279ad6931adb9a6e9..d3253b02c70c714cf1bad93f92164f974814fc88 100644 (file)
@@ -599,6 +599,24 @@ public:
    *             the log versions even if we don't have a full map in store.
    */
   virtual void encode_trim(MonitorDBStore::Transaction *t);
+  /**
+   *
+   */
+  virtual bool should_trim() {
+    bool want_trim = service_should_trim();
+
+    if (!want_trim)
+      return false;
+
+    if (g_conf->paxos_service_trim_min > 0) {
+      version_t trim_to = get_trim_to();
+      version_t first = get_first_committed();
+
+      if ((trim_to > 0) && trim_to > first)
+        return ((trim_to - first) >= (version_t)g_conf->paxos_service_trim_min);
+    }
+    return true;
+  }
   /**
    * Check if we should trim.
    *
@@ -608,7 +626,7 @@ public:
    *
    * @returns true if we should trim; false otherwise.
    */
-  virtual bool should_trim() {
+  virtual bool service_should_trim() {
     update_trim();
     return (get_trim_to() > 0);
   }