From 13bb2460e5948ed76e9b40c7ed99adc45c572f43 Mon Sep 17 00:00:00 2001 From: Leif Hedstrom Date: Mon, 19 Dec 2022 19:10:40 -0700 Subject: [PATCH] This adds a simple (static) metric for counting cache stripes With this patch, we get metrics like proxy.process.cache.stripes 4 proxy.process.cache.volume_0.stripes 2 proxy.process.cache.volume_1.stripes 2 --- iocore/cache/Cache.cc | 9 ++++++++- iocore/cache/P_CacheInternal.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc index 87aca40738d..0a3cf564148 100644 --- a/iocore/cache/Cache.cc +++ b/iocore/cache/Cache.cc @@ -997,6 +997,7 @@ CacheProcessor::cacheInitialized() vol_total_cache_bytes = gvol[i]->len - gvol[i]->dirlen(); total_cache_bytes += vol_total_cache_bytes; CACHE_VOL_SUM_DYN_STAT(cache_bytes_total_stat, vol_total_cache_bytes); + CACHE_VOL_SUM_DYN_STAT(cache_stripes_stat, 1); // Count the cache stripes Debug("cache_init", "CacheProcessor::cacheInitialized - total_cache_bytes = %" PRId64 " = %" PRId64 "Mb", total_cache_bytes, total_cache_bytes / (1024 * 1024)); @@ -2690,6 +2691,7 @@ cplist_reconfigure() int volume_number; off_t size_in_blocks; ConfigVol *config_vol; + int assignedVol = 0; // Number of assigned volumes gnvol = 0; if (config_volumes.num_volumes == 0) { @@ -2727,7 +2729,6 @@ cplist_reconfigure() cp->num_vols += dp[0]->num_volblocks; cp->disk_vols[i] = dp[0]; } - } else { for (int i = 0; i < gndisks; i++) { if (gdisks[i]->header->num_volumes == 1 && gdisks[i]->disk_vols[0]->vol_number == 0) { @@ -2748,6 +2749,8 @@ cplist_reconfigure() // in such a way forced volumes will not impact volume percentage calculations. if (-1 == gdisks[i]->forced_volume_num) { tot_space_in_blks += (gdisks[i]->num_usable_blocks / blocks_per_vol) * blocks_per_vol; + } else { + ++assignedVol; } } @@ -2915,6 +2918,9 @@ cplist_reconfigure() gnvol += cp->num_vols; } } + + GLOBAL_CACHE_SET_DYN_STAT(cache_stripes_stat, gnvol + assignedVol); + return 0; } @@ -3055,6 +3061,7 @@ register_cache_stats(RecRawStatBlock *rsb, const char *prefix) reg_int("bytes_used", cache_bytes_used_stat, rsb, prefix, cache_stats_bytes_used_cb); REG_INT("bytes_total", cache_bytes_total_stat); + REG_INT("stripes", cache_stripes_stat); REG_INT("ram_cache.total_bytes", cache_ram_cache_bytes_total_stat); REG_INT("ram_cache.bytes_used", cache_ram_cache_bytes_stat); REG_INT("ram_cache.hits", cache_ram_cache_hits_stat); diff --git a/iocore/cache/P_CacheInternal.h b/iocore/cache/P_CacheInternal.h index 22c87830f8c..e6c25849e7f 100644 --- a/iocore/cache/P_CacheInternal.h +++ b/iocore/cache/P_CacheInternal.h @@ -100,6 +100,7 @@ struct EvacuationBlock; enum { cache_bytes_used_stat, cache_bytes_total_stat, + cache_stripes_stat, cache_ram_cache_bytes_stat, cache_ram_cache_bytes_total_stat, cache_direntries_total_stat,