]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: change ReplicatedPG::object_contexts to SharedLRU
authorDong Yuan <yuandong1222@gmail.com>
Wed, 12 Nov 2014 09:16:25 +0000 (09:16 +0000)
committerDong Yuan <yuandong1222@gmail.com>
Thu, 18 Dec 2014 10:52:24 +0000 (10:52 +0000)
The ReplicatedPG now will cache the ObjectContext to avoid repeated
construction using SharedLRU. The cache is per PG, and new config
option osd_pg_object_context_cache_count which is 64 by default, is
used to specify how many ObjectContexts will be cached for each PG.

When the PG is not primary, the object_contexts cache will be cleared.

Signed-off-by: Dong Yuan <yuandong1222@gmail.com>
src/common/config_opts.h
src/osd/ReplicatedPG.cc
src/osd/ReplicatedPG.h

index 276d4ec6c9f0d392e60415d2c433a4c997c735d5..318e9428fd3557366c0add08569cdcf6d92ae6f4 100644 (file)
@@ -604,6 +604,8 @@ OPTION(osd_target_transaction_size, OPT_INT, 30)     // to adjust various transa
 OPTION(osd_failsafe_full_ratio, OPT_FLOAT, .97) // what % full makes an OSD "full" (failsafe)
 OPTION(osd_failsafe_nearfull_ratio, OPT_FLOAT, .90) // what % full makes an OSD near full (failsafe)
 
+OPTION(osd_pg_object_context_cache_count, OPT_INT, 64)
+
 // determines whether PGLog::check() compares written out log to stored log
 OPTION(osd_debug_pg_log_writeout, OPT_BOOL, false)
 
index f088361b624f697dcd90483dde2c2091163f2c33..4a598105f1dc97ff9c5717f4cbe93d00f9ac242c 100644 (file)
@@ -1232,6 +1232,7 @@ ReplicatedPG::ReplicatedPG(OSDService *o, OSDMapRef curmap,
   pgbackend(
     PGBackend::build_pg_backend(
       _pool.info, curmap, this, coll_t(p), coll_t::make_temp_coll(p), o->store, cct)),
+  object_contexts(o->cct, g_conf->osd_pg_object_context_cache_count),
   snapset_contexts_lock("ReplicatedPG::snapset_contexts"),
   temp_seq(0),
   snap_trimmer_machine(this)
@@ -9951,6 +9952,9 @@ void ReplicatedPG::on_pool_change()
   }
   hit_set_setup();
   agent_setup();
+  if (get_role() !=0) {
+    object_contexts.clear();
+  }
 }
 
 // clear state.  called on recovery completion AND cancellation.
index 51636cde49a8491d32f9a34fc5c14c1f540d5da5..f728aba02ec79ccc9e34e26733d502b357455f77 100644 (file)
@@ -886,7 +886,7 @@ protected:
   friend struct C_OnPushCommit;
 
   // projected object info
-  SharedPtrRegistry<hobject_t, ObjectContext> object_contexts;
+  SharedLRU<hobject_t, ObjectContext> object_contexts;
   // map from oid.snapdir() to SnapSetContext *
   map<hobject_t, SnapSetContext*> snapset_contexts;
   Mutex snapset_contexts_lock;