Skip to content

Commit

Permalink
display HOT/WARM tail age in stats items
Browse files Browse the repository at this point in the history
  • Loading branch information
dormando committed Jan 30, 2017
1 parent e2b1421 commit 196270f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions doc/protocol.txt
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,8 @@ number_hot Number of items presently stored in the HOT LRU.
number_warm Number of items presently stored in the WARM LRU.
number_cold Number of items presently stored in the COLD LRU.
number_temp Number of items presently stored in the TEMPORARY LRU.
age_hot Age of the oldest item in HOT LRU.
age_warm Age of the oldest item in WARM LRU.
age Age of the oldest item in the LRU.
evicted Number of times an item had to be evicted from the LRU
before it expired.
Expand Down
11 changes: 10 additions & 1 deletion items.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,8 @@ void item_stats(ADD_STAT add_stats, void *c) {
int i;
unsigned int size = 0;
unsigned int age = 0;
unsigned int age_hot = 0;
unsigned int age_warm = 0;
unsigned int lru_size_map[4];
const char *fmt = "items:%d:%s";
char key_str[STAT_KEY_LEN];
Expand All @@ -626,8 +628,13 @@ void item_stats(ADD_STAT add_stats, void *c) {
totals.direct_reclaims += itemstats[i].direct_reclaims;
size += sizes[i];
lru_size_map[x] = sizes[i];
if (lru_type_map[x] == COLD_LRU && tails[i] != NULL)
if (lru_type_map[x] == COLD_LRU && tails[i] != NULL) {
age = current_time - tails[i]->time;
} else if (lru_type_map[x] == HOT_LRU && tails[i] != NULL) {
age_hot = current_time - tails[i]->time;
} else if (lru_type_map[x] == WARM_LRU && tails[i] != NULL) {
age_warm = current_time - tails[i]->time;
}
if (lru_type_map[x] == COLD_LRU)
totals.evicted_time = itemstats[i].evicted_time;
pthread_mutex_unlock(&lru_locks[i]);
Expand All @@ -642,6 +649,8 @@ void item_stats(ADD_STAT add_stats, void *c) {
if (settings.temp_lru) {
APPEND_NUM_FMT_STAT(fmt, n, "number_temp", "%u", lru_size_map[3]);
}
APPEND_NUM_FMT_STAT(fmt, n, "age_hot", "%u", age_hot);
APPEND_NUM_FMT_STAT(fmt, n, "age_warm", "%u", age_warm);
}
APPEND_NUM_FMT_STAT(fmt, n, "age", "%u", age);
APPEND_NUM_FMT_STAT(fmt, n, "evicted",
Expand Down

0 comments on commit 196270f

Please sign in to comment.