From 1a8373c9b2eb3fc23cdd160c0a57728dd1c25497 Mon Sep 17 00:00:00 2001 From: dormando Date: Mon, 8 May 2017 15:17:23 -0700 Subject: per-LRU hits breakdown no actual speed loss. emulate the slab_stats "get_hits" by totalling up the per-LRU get_hits. could sub-LRU many stats but should use a different command/interface for that. --- items.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'items.c') diff --git a/items.c b/items.c index 556ba5a..f3db9e8 100644 --- a/items.c +++ b/items.c @@ -39,6 +39,10 @@ typedef struct { uint64_t moves_to_warm; uint64_t moves_within_lru; uint64_t direct_reclaims; + uint64_t hits_to_hot; + uint64_t hits_to_warm; + uint64_t hits_to_cold; + uint64_t hits_to_temp; rel_time_t evicted_time; } itemstats_t; @@ -663,6 +667,8 @@ void item_stats_totals(ADD_STAT add_stats, void *c) { } void item_stats(ADD_STAT add_stats, void *c) { + struct thread_stats thread_stats; + threadlocal_stats_aggregate(&thread_stats); itemstats_t totals; int n; for (n = 0; n < MAX_NUMBER_OF_SLAB_CLASSES; n++) { @@ -707,6 +713,20 @@ void item_stats(ADD_STAT add_stats, void *c) { } if (lru_type_map[x] == COLD_LRU) totals.evicted_time = itemstats[i].evicted_time; + switch (lru_type_map[x]) { + case HOT_LRU: + totals.hits_to_hot = thread_stats.lru_hits[i]; + break; + case WARM_LRU: + totals.hits_to_warm = thread_stats.lru_hits[i]; + break; + case COLD_LRU: + totals.hits_to_cold = thread_stats.lru_hits[i]; + break; + case TEMP_LRU: + totals.hits_to_temp = thread_stats.lru_hits[i]; + break; + } pthread_mutex_unlock(&lru_locks[i]); } if (size == 0) @@ -758,6 +778,18 @@ void item_stats(ADD_STAT add_stats, void *c) { "%llu", (unsigned long long)totals.moves_within_lru); APPEND_NUM_FMT_STAT(fmt, n, "direct_reclaims", "%llu", (unsigned long long)totals.direct_reclaims); + APPEND_NUM_FMT_STAT(fmt, n, "hits_to_hot", + "%llu", (unsigned long long)totals.hits_to_hot); + + APPEND_NUM_FMT_STAT(fmt, n, "hits_to_warm", + "%llu", (unsigned long long)totals.hits_to_warm); + + APPEND_NUM_FMT_STAT(fmt, n, "hits_to_cold", + "%llu", (unsigned long long)totals.hits_to_cold); + + APPEND_NUM_FMT_STAT(fmt, n, "hits_to_temp", + "%llu", (unsigned long long)totals.hits_to_temp); + } } -- cgit v1.2.1