[memcached] sgrimm,
r418: Only reposition items in the LRU queue o...
commits at code.sixapart.com
commits at code.sixapart.com
Sun Oct 15 08:45:02 UTC 2006
Only reposition items in the LRU queue once a minute. This reduces the number
of memory writes required to handle frequently-accessed items.
U branches/performance/server/items.c
Modified: branches/performance/server/items.c
===================================================================
--- branches/performance/server/items.c 2006-10-15 08:28:25 UTC (rev 417)
+++ branches/performance/server/items.c 2006-10-15 08:45:01 UTC (rev 418)
@@ -19,6 +19,12 @@
#include "memcached.h"
+/*
+ * We only reposition items in the LRU queue if they haven't been repositioned
+ * in this many seconds. That saves us from churning on frequently-accessed
+ * items.
+ */
+#define ITEM_UPDATE_INTERVAL 60
#define LARGEST_ID 255
static item *heads[LARGEST_ID];
@@ -216,11 +222,13 @@
}
void item_update(item *it) {
- assert((it->it_flags & ITEM_SLABBED) == 0);
+ if (it->time < current_time - ITEM_UPDATE_INTERVAL) {
+ assert((it->it_flags & ITEM_SLABBED) == 0);
- item_unlink_q(it);
- it->time = current_time;
- item_link_q(it);
+ item_unlink_q(it);
+ it->time = current_time;
+ item_link_q(it);
+ }
}
int item_replace(item *it, item *new_it) {
More information about the memcached-commits
mailing list