From: Xinyu Huang Date: Tue, 12 Jul 2022 10:19:04 +0000 (+0000) Subject: crimson/os/seastore/cache: fine-grained lru cache control with GC X-Git-Tag: v18.0.0~518^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8a09b9b457cc506b2525988a119fc488c6e806da;p=ceph.git crimson/os/seastore/cache: fine-grained lru cache control with GC 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 --- diff --git a/src/crimson/os/seastore/cache.cc b/src/crimson/os/seastore/cache.cc index 64ce9217807..c2f88f2df82 100644 --- a/src/crimson/os/seastore/cache.cc +++ b/src/crimson/os/seastore/cache.cc @@ -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()) diff --git a/src/crimson/os/seastore/cache.h b/src/crimson/os/seastore/cache.h index 6913851f243..a0cd4e178f9 100644 --- a/src/crimson/os/seastore/cache.h +++ b/src/crimson/os/seastore/cache.h @@ -294,12 +294,12 @@ public: get_extent_ret 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( 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( @@ -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);