From c09acb0a06d3cf1a616f9afdaef8936a0f71e9b2 Mon Sep 17 00:00:00 2001 From: zhengyu Date: Tue, 17 Jun 2025 14:25:58 +0800 Subject: [PATCH] [enhancement](cloud) monitor evict size of file cache active gc (#51197) monitor file cache gc, i.e. eviction caused by bad compaction, tablet meta removal(drop table/partion or rebalance) Signed-off-by: zhengyu --- be/src/io/cache/block_file_cache.cpp | 6 ++++++ be/src/io/cache/block_file_cache.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/be/src/io/cache/block_file_cache.cpp b/be/src/io/cache/block_file_cache.cpp index c55e9dac76c180..1e16d79dc5c057 100644 --- a/be/src/io/cache/block_file_cache.cpp +++ b/be/src/io/cache/block_file_cache.cpp @@ -87,6 +87,10 @@ BlockFileCache::BlockFileCache(const std::string& cache_base_path, _cache_base_path.c_str(), "file_cache_ttl_cache_evict_size"); _total_evict_size_metrics = std::make_shared>( _cache_base_path.c_str(), "file_cache_total_evict_size"); + _gc_evict_bytes_metrics = std::make_shared>(_cache_base_path.c_str(), + "file_cache_gc_evict_bytes"); + _gc_evict_count_metrics = std::make_shared>(_cache_base_path.c_str(), + "file_cache_gc_evict_count"); _evict_by_time_metrics_matrix[FileCacheType::DISPOSABLE][FileCacheType::NORMAL] = std::make_shared>(_cache_base_path.c_str(), @@ -1146,6 +1150,8 @@ void BlockFileCache::remove_if_cached_async(const UInt128Wrapper& file_key) { std::vector to_remove; if (iter != _files.end()) { for (auto& [_, cell] : iter->second) { + *_gc_evict_bytes_metrics << cell.size(); + *_gc_evict_count_metrics << 1; if (cell.releasable()) { to_remove.push_back(&cell); } else { diff --git a/be/src/io/cache/block_file_cache.h b/be/src/io/cache/block_file_cache.h index c12b03cc998792..7c046cc162783a 100644 --- a/be/src/io/cache/block_file_cache.h +++ b/be/src/io/cache/block_file_cache.h @@ -546,6 +546,8 @@ class BlockFileCache { std::shared_ptr> _cur_disposable_queue_cache_size_metrics; std::array>, 4> _queue_evict_size_metrics; std::shared_ptr> _total_evict_size_metrics; + std::shared_ptr> _gc_evict_bytes_metrics; + std::shared_ptr> _gc_evict_count_metrics; std::shared_ptr> _evict_by_time_metrics_matrix[4][4]; std::shared_ptr> _evict_by_size_metrics_matrix[4][4]; std::shared_ptr> _evict_by_self_lru_metrics_matrix[4];