]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/cache: fine-grained lru cache control with GC 47021/head
authorXinyu Huang <xinyu.huang@intel.com>
Tue, 12 Jul 2022 10:19:04 +0000 (10:19 +0000)
committerXinyu Huang <xinyu.huang@intel.com>
Wed, 13 Jul 2022 01:42:06 +0000 (01:42 +0000)
GC transaction is not sourced by user behaviors, so the extent read
operations from GC transaction don’t satisfy the time locality
principle. These extents should not be added to LRU cache.

Signed-off-by: Xinyu Huang <xinyu.huang@intel.com>
src/crimson/os/seastore/cache.cc
src/crimson/os/seastore/cache.h

index 64ce9217807da765b3e312ad960d5243d8e834ec..c2f88f2df82abfe47c548eea92b2e7f131d3e0d3 100644 (file)
@@ -91,7 +91,8 @@ Cache::retire_extent_ret Cache::retire_extent_addr(
               NULL_GENERATION);
     DEBUGT("retire {}~{} as placeholder, add extent -- {}",
            t, addr, length, *ext);
-    add_extent(ext);
+    const auto t_src = t.get_src();
+    add_extent(ext, &t_src);
   }
 
   // add the retired-placeholder to transaction
@@ -685,14 +686,16 @@ void Cache::register_metrics()
   );
 }
 
-void Cache::add_extent(CachedExtentRef ref)
+void Cache::add_extent(
+    CachedExtentRef ref,
+    const Transaction::src_t* p_src=nullptr)
 {
   assert(ref->is_valid());
   extents.insert(*ref);
   if (ref->is_dirty()) {
     add_to_dirty(ref);
   } else {
-    touch_extent(*ref);
+    touch_extent(*ref, p_src);
   }
 }
 
@@ -1422,7 +1425,8 @@ void Cache::complete_commit(
       i->state = CachedExtent::extent_state_t::CLEAN;
       DEBUGT("add extent as fresh, inline={} -- {}",
              t, is_inline, *i);
-      add_extent(i);
+      const auto t_src = t.get_src();
+      add_extent(i, &t_src);
       if (cleaner) {
        cleaner->mark_space_used(
          i->get_paddr(),
@@ -1546,7 +1550,8 @@ void Cache::complete_commit(
          i->get_length(),
          i->get_type(),
          seq));
-      add_extent(i);
+      const auto t_src = t.get_src();
+      add_extent(i, &t_src);
     }
   }
   if (!backref_list.empty())
index 6913851f2436e5c4ee6f832582bf1f535ec73fd6..a0cd4e178f9db079bbd84f2c828ae69180465273 100644 (file)
@@ -294,12 +294,12 @@ public:
   get_extent_ret<T> get_extent(
     paddr_t offset,                ///< [in] starting addr
     seastore_off_t length,          ///< [in] length
-    const src_ext_t* p_metric_key, ///< [in] cache query metric key
+    const src_ext_t* p_src_ext, ///< [in] cache query metric key
     Func &&extent_init_func,       ///< [in] init func for extent
     OnCache &&on_cache
   ) {
     LOG_PREFIX(Cache::get_extent);
-    auto cached = query_cache(offset, p_metric_key);
+    auto cached = query_cache(offset, p_src_ext);
     if (!cached) {
       auto ret = CachedExtent::make_cached_extent_ref<T>(
         alloc_cache_buf(length));
@@ -310,7 +310,8 @@ public:
       SUBDEBUG(seastore_cache,
           "{} {}~{} is absent, add extent and reading ... -- {}",
           T::TYPE, offset, length, *ret);
-      add_extent(ret);
+      const auto p_src = p_src_ext ? &p_src_ext->first : nullptr;
+      add_extent(ret, p_src);
       on_cache(*ret);
       extent_init_func(*ret);
       return read_extent<T>(
@@ -1293,7 +1294,12 @@ private:
   }
 
   /// Update lru for access to ref
-  void touch_extent(CachedExtent &ext) {
+  void touch_extent(
+      CachedExtent &ext,
+      const Transaction::src_t* p_src=nullptr)
+  {
+    if (p_src && is_cleaner_transaction(*p_src))
+      return;
     if (ext.is_clean() && !ext.is_placeholder()) {
       lru.move_to_top(ext);
     }
@@ -1304,7 +1310,7 @@ private:
     const journal_seq_t &);
 
   /// Add extent to extents handling dirty and refcounting
-  void add_extent(CachedExtentRef ref);
+  void add_extent(CachedExtentRef ref, const Transaction::src_t* t_src);
 
   /// Mark exising extent ref dirty -- mainly for replay
   void mark_dirty(CachedExtentRef ref);