This is an automated email from the ASF dual-hosted git repository. lihaopeng pushed a commit to branch branch-3.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push: new 2159ffcd51a [Exec)(cache) add element count in LRU cache (#43458) 2159ffcd51a is described below commit 2159ffcd51a401693b583f07286c3c73563217ea Author: HappenLee <happen...@hotmail.com> AuthorDate: Mon Nov 11 17:32:30 2024 +0800 [Exec)(cache) add element count in LRU cache (#43458) cherry-pick #41199 --- be/src/olap/lru_cache.cpp | 8 ++++++++ be/src/olap/lru_cache.h | 4 ++++ be/src/pipeline/query_cache/query_cache.cpp | 2 +- be/src/runtime/memory/lru_cache_policy.h | 2 ++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/be/src/olap/lru_cache.cpp b/be/src/olap/lru_cache.cpp index 6e5bb2fa315..b0ad59b6c8d 100644 --- a/be/src/olap/lru_cache.cpp +++ b/be/src/olap/lru_cache.cpp @@ -700,6 +700,14 @@ int64_t ShardedLRUCache::get_usage() { return total_usage; } +size_t ShardedLRUCache::get_element_count() { + size_t total_element_count = 0; + for (int i = 0; i < _num_shards; i++) { + total_element_count += _shards[i]->get_element_count(); + } + return total_element_count; +} + void ShardedLRUCache::update_cache_metrics() const { size_t capacity = 0; size_t total_usage = 0; diff --git a/be/src/olap/lru_cache.h b/be/src/olap/lru_cache.h index de7084382d7..ba2dd2b5c52 100644 --- a/be/src/olap/lru_cache.h +++ b/be/src/olap/lru_cache.h @@ -230,6 +230,8 @@ public: virtual PrunedInfo set_capacity(size_t capacity) = 0; virtual size_t get_capacity() = 0; + virtual size_t get_element_count() = 0; + private: DISALLOW_COPY_AND_ASSIGN(Cache); }; @@ -404,6 +406,7 @@ public: PrunedInfo prune() override; PrunedInfo prune_if(CachePrunePredicate pred, bool lazy_mode = false) override; int64_t get_usage() override; + size_t get_element_count() override; PrunedInfo set_capacity(size_t capacity) override; size_t get_capacity() override; @@ -467,6 +470,7 @@ public: int64_t get_usage() override { return 0; }; PrunedInfo set_capacity(size_t capacity) override { return {0, 0}; }; size_t get_capacity() override { return 0; }; + size_t get_element_count() override { return 0; }; }; } // namespace doris diff --git a/be/src/pipeline/query_cache/query_cache.cpp b/be/src/pipeline/query_cache/query_cache.cpp index 20e342e140f..b69e202d67b 100644 --- a/be/src/pipeline/query_cache/query_cache.cpp +++ b/be/src/pipeline/query_cache/query_cache.cpp @@ -66,4 +66,4 @@ bool QueryCache::lookup(const CacheKey& key, int64_t version, doris::QueryCacheH return false; } -} // namespace doris \ No newline at end of file +} // namespace doris diff --git a/be/src/runtime/memory/lru_cache_policy.h b/be/src/runtime/memory/lru_cache_policy.h index 7b5a8ab9fec..f65a1e23e1a 100644 --- a/be/src/runtime/memory/lru_cache_policy.h +++ b/be/src/runtime/memory/lru_cache_policy.h @@ -132,6 +132,8 @@ public: int64_t get_usage() { return _cache->get_usage(); } + size_t get_element_count() { return _cache->get_element_count(); } + size_t get_capacity() override { return _cache->get_capacity(); } uint64_t new_id() { return _cache->new_id(); }; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org