0
@@ -27,12 +27,19 @@ static uint64_t get_cas_id();
0
#define ITEM_UPDATE_INTERVAL 60
0
+ unsigned int outofmemory;
0
static item *heads[LARGEST_ID];
0
static item *tails[LARGEST_ID];
0
+static itemstats_t itemstats[LARGEST_ID];
0
static unsigned int sizes[LARGEST_ID];
0
+ memset(itemstats, 0, sizeof(itemstats_t) * LARGEST_ID);
0
for(i = 0; i < LARGEST_ID; i++) {
0
@@ -97,7 +104,10 @@ item *do_item_alloc(char *key, const size_t nkey, const int flags, const rel_tim
0
* we're out of luck at this point...
0
- if (settings.evict_to_free == 0) return NULL;
0
+ if (settings.evict_to_free == 0) {
0
+ itemstats[id].outofmemory++;
0
* try to get one off the right LRU
0
@@ -106,21 +116,28 @@ item *do_item_alloc(char *key, const size_t nkey, const int flags, const rel_tim
0
- if (tails[id] == 0) return NULL;
0
+ itemstats[id].outofmemory++;
0
for (search = tails[id]; tries > 0 && search != NULL; tries--, search=search->prev) {
0
if (search->refcount == 0) {
0
- if (search->exptime == 0 || search->exptime > current_time) {
0
+ if (search->exptime == 0 || search->exptime > current_time) {
0
+ itemstats[id].evicted++;
0
do_item_unlink(search);
0
it = slabs_alloc(ntotal, id);
0
- if (it == 0) return NULL;
0
+ itemstats[id].outofmemory++;
0
assert(it->slabs_clsid == 0);
0
@@ -311,7 +328,7 @@ char *do_item_cachedump(const unsigned int slabs_clsid, const unsigned int limit
0
char *do_item_stats(int *bytes) {
0
- size_t bufleft = (size_t) LARGEST_ID *
80;
0
+ size_t bufleft = (size_t) LARGEST_ID *
160;
0
char *buffer = malloc(bufleft);
0
char *bufcurr = buffer;
0
rel_time_t now = current_time;
0
@@ -324,8 +341,13 @@ char *do_item_stats(int *bytes) {
0
for (i = 0; i < LARGEST_ID; i++) {
0
if (tails[i] != NULL) {
0
- linelen = snprintf(bufcurr, bufleft, "STAT items:%d:number %u\r\nSTAT items:%d:age %u\r\n",
0
- i, sizes[i], i, now - tails[i]->time);
0
+ linelen = snprintf(bufcurr, bufleft,
0
+ "STAT items:%d:number %u\r\n"
0
+ "STAT items:%d:age %u\r\n"
0
+ "STAT items:%d:evicted %u\r\n"
0
+ "STAT items:%d:outofmemory %u\r\n",
0
+ i, sizes[i], i, now - tails[i]->time, i,
0
+ itemstats[i].evicted, i, itemstats[i].outofmemory);
0
if (linelen + sizeof("END\r\n") < bufleft) {
Comments
No one has commented yet.