From: Igor Fedotov Date: Wed, 1 Feb 2023 21:19:38 +0000 (+0300) Subject: kv/RocksDBStore: don't use real wholespace iterator for prefixed access X-Git-Tag: v19.0.0~1575^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=46c0a61f578c02e8a5cf4e29415989ae6ec4681c;p=ceph.git kv/RocksDBStore: don't use real wholespace iterator for prefixed access We can bound to default CF when here are no matching CF for a specified prefix. No need to use real wholespace iterator running over every CF. Hence we might benefit from not iterating over large but useless CFs, e.g. OMAP related ones. Signed-off-by: Igor Fedotov --- diff --git a/src/kv/KeyValueDB.h b/src/kv/KeyValueDB.h index 98bf0c07c43f4..9cfb4482706c9 100644 --- a/src/kv/KeyValueDB.h +++ b/src/kv/KeyValueDB.h @@ -322,6 +322,12 @@ private: return generic_iter->status(); } }; +protected: + Iterator make_iterator(const std::string &prefix, WholeSpaceIterator w_iter) { + return std::make_shared( + prefix, + w_iter); + } public: typedef uint32_t IteratorOpts; static const uint32_t ITERATOR_NOCACHE = 1; @@ -333,8 +339,7 @@ public: virtual WholeSpaceIterator get_wholespace_iterator(IteratorOpts opts = 0) = 0; virtual Iterator get_iterator(const std::string &prefix, IteratorOpts opts = 0, IteratorBounds bounds = IteratorBounds()) { - return std::make_shared( - prefix, + return make_iterator(prefix, get_wholespace_iterator(opts)); } diff --git a/src/kv/RocksDBStore.cc b/src/kv/RocksDBStore.cc index bd716d2093f30..b421098f78cc3 100644 --- a/src/kv/RocksDBStore.cc +++ b/src/kv/RocksDBStore.cc @@ -3011,7 +3011,13 @@ KeyValueDB::Iterator RocksDBStore::get_iterator(const std::string& prefix, Itera std::move(bounds)); } } else { - return KeyValueDB::get_iterator(prefix, opts); + // use wholespace engine if no cfs are configured + // or use default cf otherwise as there is no + // matching cf for the specified prefix. + auto w_it = cf_handles.size() == 0 || prefix.empty() ? + get_wholespace_iterator(opts) : + get_default_cf_iterator(); + return KeyValueDB::make_iterator(prefix, w_it); } }