Skip to content

Commit

Permalink
This adds a simple (static) metric for counting cache spans
Browse files Browse the repository at this point in the history
With this patch, we get metrics like

proxy.process.cache.spans 4
proxy.process.cache.volume_0.spans 2
proxy.process.cache.volume_1.spans 2
  • Loading branch information
zwoop committed Dec 20, 2022
1 parent 4ebcba0 commit 40023d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion iocore/cache/Cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,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_spans_stat, 1); // Count the spans
Debug("cache_init", "CacheProcessor::cacheInitialized - total_cache_bytes = %" PRId64 " = %" PRId64 "Mb",
total_cache_bytes, total_cache_bytes / (1024 * 1024));

Expand Down Expand Up @@ -2689,6 +2690,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) {
Expand Down Expand Up @@ -2726,7 +2728,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) {
Expand All @@ -2747,6 +2748,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;
}
}

Expand Down Expand Up @@ -2914,6 +2917,9 @@ cplist_reconfigure()
gnvol += cp->num_vols;
}
}

GLOBAL_CACHE_SET_DYN_STAT(cache_spans_stat, gnvol + assignedVol);

return 0;
}

Expand Down Expand Up @@ -3054,6 +3060,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("spans", cache_spans_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);
Expand Down
1 change: 1 addition & 0 deletions iocore/cache/P_CacheInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ struct EvacuationBlock;
enum {
cache_bytes_used_stat,
cache_bytes_total_stat,
cache_spans_stat,
cache_ram_cache_bytes_stat,
cache_ram_cache_bytes_total_stat,
cache_direntries_total_stat,
Expand Down

0 comments on commit 40023d2

Please sign in to comment.