This is an automated email from the ASF dual-hosted git repository.
masaori pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new c6d0b6cfbe Update cache metrics after initialized (#12430)
c6d0b6cfbe is described below
commit c6d0b6cfbe0fa2f1bfa343c546528f376d8bb261
Author: Masaori Koshiba <[email protected]>
AuthorDate: Tue Aug 12 08:52:23 2025 +0900
Update cache metrics after initialized (#12430)
---
src/iocore/cache/CacheProcessor.cc | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/src/iocore/cache/CacheProcessor.cc
b/src/iocore/cache/CacheProcessor.cc
index 2a8c9bb7a5..67e2804cec 100644
--- a/src/iocore/cache/CacheProcessor.cc
+++ b/src/iocore/cache/CacheProcessor.cc
@@ -131,6 +131,10 @@ CacheProcessor::start(int, size_t)
void
CachePeriodicMetricsUpdate()
{
+ if (cacheProcessor.initialized != CacheInitState::INITIALIZED) {
+ return;
+ }
+
int64_t total_sum = 0;
// Make sure the bytes_used per volume is always reset to zero, this can
update the
@@ -140,21 +144,19 @@ CachePeriodicMetricsUpdate()
ts::Metrics::Gauge::store(gstripes[i]->cache_vol->vol_rsb.bytes_used, 0);
}
- if (cacheProcessor.initialized == CacheInitState::INITIALIZED) {
- for (int i = 0; i < gnstripes; ++i) {
- StripeSM *v = gstripes[i];
- int64_t used = cache_bytes_used(i);
+ for (int i = 0; i < gnstripes; ++i) {
+ StripeSM *v = gstripes[i];
+ int64_t used = cache_bytes_used(i);
- ts::Metrics::Gauge::increment(v->cache_vol->vol_rsb.bytes_used, used);
// This assumes they start at zero
- total_sum += used;
- }
+ ts::Metrics::Gauge::increment(v->cache_vol->vol_rsb.bytes_used, used); //
This assumes they start at zero
+ total_sum += used;
+ }
- // Also update the global (not per volume) metrics
- int64_t total = ts::Metrics::Gauge::load(cache_rsb.bytes_total);
+ // Also update the global (not per volume) metrics
+ int64_t total = ts::Metrics::Gauge::load(cache_rsb.bytes_total);
- ts::Metrics::Gauge::store(cache_rsb.bytes_used, total_sum);
- ts::Metrics::Gauge::store(cache_rsb.percent_full, total ? (total_sum *
100) / total : 0);
- }
+ ts::Metrics::Gauge::store(cache_rsb.bytes_used, total_sum);
+ ts::Metrics::Gauge::store(cache_rsb.percent_full, total ? (total_sum * 100)
/ total : 0);
}
// ToDo: This gets called as part of librecords collection continuation,
probably change this later.