void do_item_stats(ADD_STAT add_stats, void *c) { int i; for (i = 0; i < LARGEST_ID; i++) { if (tails[i] != NULL) { const char *fmt = "items:%d:%s"; char key_str[STAT_KEY_LEN]; char val_str[STAT_VAL_LEN]; int klen = 0, vlen = 0; APPEND_NUM_FMT_STAT(fmt, i, "number", "%u", sizes[i]); APPEND_NUM_FMT_STAT(fmt, i, "age", "%u", tails[i]->time); APPEND_NUM_FMT_STAT(fmt, i, "evicted", "%u", itemstats[i].evicted); APPEND_NUM_FMT_STAT(fmt, i, "evicted_nonzero", "%u", itemstats[i].evicted_nonzero); APPEND_NUM_FMT_STAT(fmt, i, "evicted_time", "%u", itemstats[i].evicted_time); APPEND_NUM_FMT_STAT(fmt, i, "outofmemory", "%u", itemstats[i].outofmemory); APPEND_NUM_FMT_STAT(fmt, i, "tailrepairs", "%u", itemstats[i].tailrepairs);; APPEND_NUM_FMT_STAT(fmt, i, "reclaimed", "%u", itemstats[i].reclaimed);; } } /* getting here means both ascii and binary terminators fit */ add_stats(NULL, 0, NULL, 0, c); }
void do_item_stats(ADD_STAT add_stats, void *c) { int i; for (i = 0; i < LARGEST_ID; i++) { if (tails[i] != NULL) { const char *fmt = "items:%d:%s"; char key_str[STAT_KEY_LEN]; char val_str[STAT_VAL_LEN]; int klen = 0, vlen = 0; int search = 50; while (search > 0 && tails[i] != NULL && ((settings.oldest_live != 0 && /* Item flushd */ settings.oldest_live <= current_time && tails[i]->time <= settings.oldest_live) || (tails[i]->exptime != 0 && /* and not expired */ tails[i]->exptime < current_time))) { --search; if (tails[i]->refcount == 0) { do_item_unlink(tails[i]); } else { break; } } if (tails[i] == NULL) { /* We removed all of the items in this slab class */ continue; } APPEND_NUM_FMT_STAT(fmt, i, "number", "%u", sizes[i]); APPEND_NUM_FMT_STAT(fmt, i, "age", "%u", tails[i]->time); APPEND_NUM_FMT_STAT(fmt, i, "evicted", "%u", itemstats[i].evicted); APPEND_NUM_FMT_STAT(fmt, i, "evicted_nonzero", "%u", itemstats[i].evicted_nonzero); APPEND_NUM_FMT_STAT(fmt, i, "evicted_time", "%u", itemstats[i].evicted_time); APPEND_NUM_FMT_STAT(fmt, i, "outofmemory", "%u", itemstats[i].outofmemory); APPEND_NUM_FMT_STAT(fmt, i, "tailrepairs", "%u", itemstats[i].tailrepairs);; APPEND_NUM_FMT_STAT(fmt, i, "reclaimed", "%u", itemstats[i].reclaimed);; } } /* getting here means both ascii and binary terminators fit */ add_stats(NULL, 0, NULL, 0, c); }
void do_item_stats(ADD_STAT add_stats, void *c) { syslog(LOG_INFO, "[%s:%s:%d]", __FILE__, __func__, __LINE__); int i; for (i = 0; i < LARGEST_ID; i++) { if (tails[i] != NULL) { const char *fmt = "items:%d:%s"; char key_str[STAT_KEY_LEN]; char val_str[STAT_VAL_LEN]; int klen = 0, vlen = 0; if (tails[i] == NULL) { /* We removed all of the items in this slab class */ continue; } APPEND_NUM_FMT_STAT(fmt, i, "number", "%u", sizes[i]); APPEND_NUM_FMT_STAT(fmt, i, "age", "%u", current_time - tails[i]->time); APPEND_NUM_FMT_STAT(fmt, i, "evicted", "%llu", (unsigned long long)itemstats[i].evicted); APPEND_NUM_FMT_STAT(fmt, i, "evicted_nonzero", "%llu", (unsigned long long)itemstats[i].evicted_nonzero); APPEND_NUM_FMT_STAT(fmt, i, "evicted_time", "%u", itemstats[i].evicted_time); APPEND_NUM_FMT_STAT(fmt, i, "outofmemory", "%llu", (unsigned long long)itemstats[i].outofmemory); APPEND_NUM_FMT_STAT(fmt, i, "tailrepairs", "%llu", (unsigned long long)itemstats[i].tailrepairs); APPEND_NUM_FMT_STAT(fmt, i, "reclaimed", "%llu", (unsigned long long)itemstats[i].reclaimed); APPEND_NUM_FMT_STAT(fmt, i, "expired_unfetched", "%llu", (unsigned long long)itemstats[i].expired_unfetched); APPEND_NUM_FMT_STAT(fmt, i, "evicted_unfetched", "%llu", (unsigned long long)itemstats[i].evicted_unfetched); } } /* getting here means both ascii and binary terminators fit */ add_stats(NULL, 0, NULL, 0, c); }
void item_stats(ADD_STAT add_stats, void *c) { itemstats_t totals; int n; for (n = 0; n < MAX_NUMBER_OF_SLAB_CLASSES; n++) { memset(&totals, 0, sizeof(itemstats_t)); int x; int i; unsigned int size = 0; unsigned int age = 0; unsigned int lru_size_map[4]; const char *fmt = "items:%d:%s"; char key_str[STAT_KEY_LEN]; char val_str[STAT_VAL_LEN]; int klen = 0, vlen = 0; for (x = 0; x < 4; x++) { i = n | lru_type_map[x]; pthread_mutex_lock(&lru_locks[i]); totals.evicted += itemstats[i].evicted; totals.evicted_nonzero += itemstats[i].evicted_nonzero; totals.outofmemory += itemstats[i].outofmemory; totals.tailrepairs += itemstats[i].tailrepairs; totals.reclaimed += itemstats[i].reclaimed; totals.expired_unfetched += itemstats[i].expired_unfetched; totals.evicted_unfetched += itemstats[i].evicted_unfetched; totals.crawler_reclaimed += itemstats[i].crawler_reclaimed; totals.crawler_items_checked += itemstats[i].crawler_items_checked; totals.lrutail_reflocked += itemstats[i].lrutail_reflocked; totals.moves_to_cold += itemstats[i].moves_to_cold; totals.moves_to_warm += itemstats[i].moves_to_warm; totals.moves_within_lru += itemstats[i].moves_within_lru; 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) age = 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]); } if (size == 0) continue; APPEND_NUM_FMT_STAT(fmt, n, "number", "%u", size); if (settings.lru_maintainer_thread) { APPEND_NUM_FMT_STAT(fmt, n, "number_hot", "%u", lru_size_map[0]); APPEND_NUM_FMT_STAT(fmt, n, "number_warm", "%u", lru_size_map[1]); APPEND_NUM_FMT_STAT(fmt, n, "number_cold", "%u", lru_size_map[2]); if (settings.expirezero_does_not_evict) { APPEND_NUM_FMT_STAT(fmt, n, "number_noexp", "%u", lru_size_map[3]); } } APPEND_NUM_FMT_STAT(fmt, n, "age", "%u", age); APPEND_NUM_FMT_STAT(fmt, n, "evicted", "%llu", (unsigned long long)totals.evicted); APPEND_NUM_FMT_STAT(fmt, n, "evicted_nonzero", "%llu", (unsigned long long)totals.evicted_nonzero); APPEND_NUM_FMT_STAT(fmt, n, "evicted_time", "%u", totals.evicted_time); APPEND_NUM_FMT_STAT(fmt, n, "outofmemory", "%llu", (unsigned long long)totals.outofmemory); APPEND_NUM_FMT_STAT(fmt, n, "tailrepairs", "%llu", (unsigned long long)totals.tailrepairs); APPEND_NUM_FMT_STAT(fmt, n, "reclaimed", "%llu", (unsigned long long)totals.reclaimed); APPEND_NUM_FMT_STAT(fmt, n, "expired_unfetched", "%llu", (unsigned long long)totals.expired_unfetched); APPEND_NUM_FMT_STAT(fmt, n, "evicted_unfetched", "%llu", (unsigned long long)totals.evicted_unfetched); APPEND_NUM_FMT_STAT(fmt, n, "crawler_reclaimed", "%llu", (unsigned long long)totals.crawler_reclaimed); APPEND_NUM_FMT_STAT(fmt, n, "crawler_items_checked", "%llu", (unsigned long long)totals.crawler_items_checked); APPEND_NUM_FMT_STAT(fmt, n, "lrutail_reflocked", "%llu", (unsigned long long)totals.lrutail_reflocked); if (settings.lru_maintainer_thread) { APPEND_NUM_FMT_STAT(fmt, n, "moves_to_cold", "%llu", (unsigned long long)totals.moves_to_cold); APPEND_NUM_FMT_STAT(fmt, n, "moves_to_warm", "%llu", (unsigned long long)totals.moves_to_warm); APPEND_NUM_FMT_STAT(fmt, n, "moves_within_lru", "%llu", (unsigned long long)totals.moves_within_lru); APPEND_NUM_FMT_STAT(fmt, n, "direct_reclaims", "%llu", (unsigned long long)totals.direct_reclaims); } } /* getting here means both ascii and binary terminators fit */ add_stats(NULL, 0, NULL, 0, c); }