Skip to content

Commit

Permalink
cst/cache: Add metric for in-memory trims
Browse files Browse the repository at this point in the history
  • Loading branch information
abhijat committed Jun 12, 2024
1 parent 63afff2 commit e256efb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/v/cloud_storage/cache_probe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ cache_probe::cache_probe() {
"Number of times could not free the expected amount of "
"space, indicating possible bug or configuration issue."))
.aggregate(aggregate_labels),
sm::make_counter(
"in_mem_trims",
[this] { return _in_mem_trims; },
sm::description("Number of times we trimmed the cache using "
"the in-memory access tracker."))
.aggregate(aggregate_labels),
});
}

Expand Down
2 changes: 2 additions & 0 deletions src/v/cloud_storage/cache_probe.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class cache_probe {
void exhaustive_trim() { ++_exhaustive_trims; }
void carryover_trim() { ++_carryover_trims; }
void failed_trim() { ++_failed_trims; }
void in_mem_trim() { ++_in_mem_trims; }

private:
uint64_t _num_puts = 0;
Expand All @@ -58,6 +59,7 @@ class cache_probe {
int64_t _exhaustive_trims{0};
int64_t _carryover_trims{0};
int64_t _failed_trims{0};
int64_t _in_mem_trims{0};

metrics::internal_metric_groups _metrics;
metrics::public_metric_groups _public_metrics;
Expand Down
1 change: 1 addition & 0 deletions src/v/cloud_storage/cache_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ ss::future<> cache::trim(
auto trim_result = co_await do_trim(
tracker_lru_entries, size_to_delete, objects_to_delete);

probe.in_mem_trim();
vlog(
cst_log.debug,
"in-memory trim result: deleted size: {}, deleted count: {}",
Expand Down

0 comments on commit e256efb

Please sign in to comment.