memory full warnings, information
Veres Lajos
vlajos at ludens.elte.hu
Sat Dec 10 23:10:35 UTC 2005
Hello,
I tried to create a stat entry showing the number of "dropped" before
expiration items.
I attached what I made.
Please verify my patch.
I'm not an C expert and maybe I failed to understand the releated
code parts.
If you think this is usefull for others feel free to merge into
upstream.
On Wed, 7 Dec 2005, Veres Lajos wrote:
> Hello,
>
> There is any way to print warnings if non-expired items are deleted for make
> space for new items?
>
> As I seen -v doesnt print nothing about memory allocations, and -M refuses
> inserts if memory is full.
>
> It would be usefull if we could see if too much items are deleted before
> theirs expirations. (=> We should add more memory.)
>
> Or maybe an hourly/daily stat would be the greatest.
>
>
--
Veres Lajos
vlajos at ludens.elte.hu
+36 20 438 5909
-------------- next part --------------
diff -ruwb memcached-1.1.12.orig/items.c memcached-1.1.12/items.c
--- memcached-1.1.12.orig/items.c 2004-09-14 19:45:48.000000000 +0200
+++ memcached-1.1.12/items.c 2005-12-10 23:52:54.000000000 +0100
@@ -64,6 +64,8 @@
if (!settings.evict_to_free) return 0;
+ stats.dropped_items += 1;
+
/*
* try to get one off the right LRU
* don't necessariuly unlink the tail because it may be locked: refcount>0
diff -ruwb memcached-1.1.12.orig/memcached.c memcached-1.1.12/memcached.c
--- memcached-1.1.12.orig/memcached.c 2005-04-05 02:10:26.000000000 +0200
+++ memcached-1.1.12/memcached.c 2005-12-10 23:54:11.000000000 +0100
@@ -73,14 +73,14 @@
}
void stats_init(void) {
- stats.curr_items = stats.total_items = stats.curr_conns = stats.total_conns = stats.conn_structs = 0;
+ stats.curr_items = stats.total_items = stats.dropped_items = stats.curr_conns = stats.total_conns = stats.conn_structs = 0;
stats.get_cmds = stats.set_cmds = stats.get_hits = stats.get_misses = 0;
stats.curr_bytes = stats.bytes_read = stats.bytes_written = 0;
stats.started = time(0);
}
void stats_reset(void) {
- stats.total_items = stats.total_conns = 0;
+ stats.total_items = stats.dropped_items = stats.total_conns = 0;
stats.get_cmds = stats.set_cmds = stats.get_hits = stats.get_misses = 0;
stats.bytes_read = stats.bytes_written = 0;
}
@@ -340,6 +340,7 @@
pos += sprintf(pos, "STAT rusage_system %ld.%06ld\r\n", usage.ru_stime.tv_sec, usage.ru_stime.tv_usec);
pos += sprintf(pos, "STAT curr_items %u\r\n", stats.curr_items);
pos += sprintf(pos, "STAT total_items %u\r\n", stats.total_items);
+ pos += sprintf(pos, "STAT dropped_items %u\r\n", stats.dropped_items);
pos += sprintf(pos, "STAT bytes %llu\r\n", stats.curr_bytes);
pos += sprintf(pos, "STAT curr_connections %u\r\n", stats.curr_conns - 1); /* ignore listening conn */
pos += sprintf(pos, "STAT total_connections %u\r\n", stats.total_conns);
diff -ruwb memcached-1.1.12.orig/memcached.h memcached-1.1.12/memcached.h
--- memcached-1.1.12.orig/memcached.h 2005-12-10 23:50:49.000000000 +0100
+++ memcached-1.1.12/memcached.h 2005-12-10 23:51:54.000000000 +0100
@@ -21,6 +21,7 @@
time_t started; /* when the process was started */
unsigned long long bytes_read;
unsigned long long bytes_written;
+ unsigned int dropped_items;
};
struct settings {
More information about the memcached
mailing list