This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.0 by this push:
     new c1f8f153338 branch-4.0: [enhancement](filecache) add readsize and 
hitsize metrics to file_cache statistics and be vars #52212 (#57851)
c1f8f153338 is described below

commit c1f8f15333890b62fc6cd6b2bc1c6f62bccf6a9b
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Nov 11 15:19:26 2025 +0800

    branch-4.0: [enhancement](filecache) add readsize and hitsize metrics to 
file_cache statistics and be vars #52212 (#57851)
    
    Cherry-picked from #52212
    
    Co-authored-by: Wen Zhenghu <[email protected]>
---
 be/src/io/cache/block_file_cache.cpp | 27 +++++++++++++++++++++++++--
 be/src/io/cache/block_file_cache.h   |  2 ++
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/be/src/io/cache/block_file_cache.cpp 
b/be/src/io/cache/block_file_cache.cpp
index 62f8e2a3f22..fcfa2bda9e7 100644
--- a/be/src/io/cache/block_file_cache.cpp
+++ b/be/src/io/cache/block_file_cache.cpp
@@ -94,6 +94,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<bvar::Adder<size_t>>(
             _cache_base_path.c_str(), "file_cache_total_evict_size");
+    _total_read_size_metrics = 
std::make_shared<bvar::Adder<size_t>>(_cache_base_path.c_str(),
+                                                                     
"file_cache_total_read_size");
+    _total_hit_size_metrics = 
std::make_shared<bvar::Adder<size_t>>(_cache_base_path.c_str(),
+                                                                    
"file_cache_total_hit_size");
     _gc_evict_bytes_metrics = 
std::make_shared<bvar::Adder<size_t>>(_cache_base_path.c_str(),
                                                                     
"file_cache_gc_evict_bytes");
     _gc_evict_count_metrics = 
std::make_shared<bvar::Adder<size_t>>(_cache_base_path.c_str(),
@@ -827,8 +831,11 @@ FileBlocksHolder BlockFileCache::get_or_set(const 
UInt128Wrapper& hash, size_t o
             *_no_warmup_num_read_blocks << file_blocks.size();
         }
         for (auto& block : file_blocks) {
+            size_t block_size = block->range().size();
+            *_total_read_size_metrics << block_size;
             if (block->state_unsafe() == FileBlock::State::DOWNLOADED) {
                 *_num_hit_blocks << 1;
+                *_total_hit_size_metrics << block_size;
                 if (!context.is_warmup) {
                     *_no_warmup_num_hit_blocks << 1;
                 }
@@ -2441,11 +2448,16 @@ std::map<std::string, double> 
BlockFileCache::get_stats() {
     stats["disposable_queue_curr_elements"] =
             (double)_cur_disposable_queue_element_count_metrics->get_value();
 
+    stats["need_evict_cache_in_advance"] = 
(double)_need_evict_cache_in_advance;
+    stats["disk_resource_limit_mode"] = (double)_disk_resource_limit_mode;
+
     stats["total_removed_counts"] = (double)_num_removed_blocks->get_value();
     stats["total_hit_counts"] = (double)_num_hit_blocks->get_value();
     stats["total_read_counts"] = (double)_num_read_blocks->get_value();
-    stats["need_evict_cache_in_advance"] = 
(double)_need_evict_cache_in_advance;
-    stats["disk_resource_limit_mode"] = (double)_disk_resource_limit_mode;
+
+    stats["total_read_size"] = (double)_total_read_size_metrics->get_value();
+    stats["total_hit_size"] = (double)_total_hit_size_metrics->get_value();
+    stats["total_removed_size"] = 
(double)_total_evict_size_metrics->get_value();
 
     return stats;
 }
@@ -2477,6 +2489,17 @@ std::map<std::string, double> 
BlockFileCache::get_stats_unsafe() {
     stats["disposable_queue_max_elements"] = 
(double)_disposable_queue.get_max_element_size();
     stats["disposable_queue_curr_elements"] = 
(double)_disposable_queue.get_elements_num_unsafe();
 
+    stats["need_evict_cache_in_advance"] = 
(double)_need_evict_cache_in_advance;
+    stats["disk_resource_limit_mode"] = (double)_disk_resource_limit_mode;
+
+    stats["total_removed_counts"] = (double)_num_removed_blocks->get_value();
+    stats["total_hit_counts"] = (double)_num_hit_blocks->get_value();
+    stats["total_read_counts"] = (double)_num_read_blocks->get_value();
+
+    stats["total_read_size"] = (double)_total_read_size_metrics->get_value();
+    stats["total_hit_size"] = (double)_total_hit_size_metrics->get_value();
+    stats["total_removed_size"] = 
(double)_total_evict_size_metrics->get_value();
+
     return stats;
 }
 
diff --git a/be/src/io/cache/block_file_cache.h 
b/be/src/io/cache/block_file_cache.h
index 512de17b52e..14399325565 100644
--- a/be/src/io/cache/block_file_cache.h
+++ b/be/src/io/cache/block_file_cache.h
@@ -515,6 +515,8 @@ private:
     std::shared_ptr<bvar::Status<size_t>> 
_cur_disposable_queue_element_count_metrics;
     std::shared_ptr<bvar::Status<size_t>> 
_cur_disposable_queue_cache_size_metrics;
     std::array<std::shared_ptr<bvar::Adder<size_t>>, 4> 
_queue_evict_size_metrics;
+    std::shared_ptr<bvar::Adder<size_t>> _total_read_size_metrics;
+    std::shared_ptr<bvar::Adder<size_t>> _total_hit_size_metrics;
     std::shared_ptr<bvar::Adder<size_t>> _total_evict_size_metrics;
     std::shared_ptr<bvar::Adder<size_t>> _gc_evict_bytes_metrics;
     std::shared_ptr<bvar::Adder<size_t>> _gc_evict_count_metrics;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to