From 7d0966a6b712078bf7d52c13669539ba619cf1fc Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 2 Nov 2010 18:59:48 +0100 Subject: [PATCH] Do not update the LRU info on key lookup when we have a saving child. With this trivial change the additional memory used while saving with a background child in presence of many read operations is zero. --- src/db.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/db.c b/src/db.c index a39a03bb..f2a0c09e 100644 --- a/src/db.c +++ b/src/db.c @@ -11,8 +11,11 @@ robj *lookupKey(redisDb *db, robj *key) { if (de) { robj *val = dictGetEntryVal(de); - /* Update the access time for the aging algorithm. */ - val->lru = server.lruclock; + /* Update the access time for the aging algorithm. + * Don't do it if we have a saving child, as this will trigger + * a copy on write madness. */ + if (server.bgsavechildpid == -1 && server.bgrewritechildpid == -1) + val->lru = server.lruclock; if (server.vm_enabled) { if (val->storage == REDIS_VM_MEMORY ||