]> git.saurik.com Git - redis.git/commitdiff
VM hash type swappability implemented. Handling of failed pthread_create() call.
authorantirez <antirez@gmail.com>
Fri, 19 Mar 2010 17:02:37 +0000 (18:02 +0100)
committerantirez <antirez@gmail.com>
Fri, 19 Mar 2010 17:02:37 +0000 (18:02 +0100)
TODO
redis.c

diff --git a/TODO b/TODO
index f9fa8f2af736a2d7887f7ae4d3cd25bb3f303344..237fb649918f626836febe2e8a7c1234a7a7d43a 100644 (file)
--- a/TODO
+++ b/TODO
@@ -8,8 +8,6 @@ VERSION 2.0 TODO
 * Save dataset / fsync() on SIGTERM
 * MULTI/EXEC should support the "EXEC FSYNC" form?
 * BLPOP & C. tests (write a non blocking Tcl client as first step)
 * Save dataset / fsync() on SIGTERM
 * MULTI/EXEC should support the "EXEC FSYNC" form?
 * BLPOP & C. tests (write a non blocking Tcl client as first step)
-* ZCOUNT sortedset min max
-* ZRANK: http://docs.google.com/viewer?a=v&q=cache:tCQaP3ZeN4YJ:courses.csail.mit.edu/6.046/spring04/handouts/ps5-sol.pdf+skip+list+rank+operation+augmented&hl=en&pid=bl&srcid=ADGEEShXuNjTcZyXw_1cq9OaWpSXy3PprjXqVzmM-LE0ETFznLyrDXJKQ_mBPNT10R8ErkoiXD9JbMw_FaoHmOA4yoGVrA7tZWiy393JwfCwuewuP93sjbkzZ_gnEp83jYhPYjThaIzw&sig=AHIEtbRF0GkYCdYRFtTJBE69senXZwFY0w
 * Once ZRANK is implemented, change the implementation of ZCOUNT to use the augmented skiplist in order to be much faster.
 * Write doc for ZCOUNT, and for open / closed intervals of sorted sets range operations.
 
 * Once ZRANK is implemented, change the implementation of ZCOUNT to use the augmented skiplist in order to be much faster.
 * Write doc for ZCOUNT, and for open / closed intervals of sorted sets range operations.
 
@@ -29,7 +27,7 @@ Virtual Memory sub-TODO:
 
 * Hashes (GET/SET/DEL/INCRBY/EXISTS/FIELDS/LEN/MSET/MGET). Special encoding for hashes with less than N elements.
 * Write documentation for APPEND
 
 * Hashes (GET/SET/DEL/INCRBY/EXISTS/FIELDS/LEN/MSET/MGET). Special encoding for hashes with less than N elements.
 * Write documentation for APPEND
-* Implement LEN, SUBSTR, PEEK, POKE, SETBIT, GETBIT
+* Implement LEN, PEEK, POKE, SETBIT, GETBIT
 
 VERSION 2.2 TODO (Fault tolerant sharding)
 ===========================================
 
 VERSION 2.2 TODO (Fault tolerant sharding)
 ===========================================
diff --git a/redis.c b/redis.c
index 7c0a86956b1fd1dd5a645a5f1cf6b47e579f8183..f272d0036cd4febaae1def59edee206945ba9008 100644 (file)
--- a/redis.c
+++ b/redis.c
@@ -8318,6 +8318,38 @@ static double computeObjectSwappability(robj *o) {
             if (z) asize += sizeof(zskiplistNode)*dictSize(d);
         }
         break;
             if (z) asize += sizeof(zskiplistNode)*dictSize(d);
         }
         break;
+    case REDIS_HASH:
+        if (o->encoding == REDIS_ENCODING_ZIPMAP) {
+            unsigned char *p = zipmapRewind((unsigned char*)o->ptr);
+            unsigned int len = zipmapLen((unsigned char*)o->ptr);
+            unsigned int klen, vlen;
+            unsigned char *key, *val;
+
+            if ((p = zipmapNext(p,&key,&klen,&val,&vlen)) == NULL) {
+                klen = 0;
+                vlen = 0;
+            }
+            asize = len*(klen+vlen+3);
+        } else if (o->encoding == REDIS_ENCODING_HT) {
+            d = o->ptr;
+            asize = sizeof(dict)+(sizeof(struct dictEntry*)*dictSlots(d));
+            if (dictSize(d)) {
+                long elesize;
+                robj *ele;
+
+                de = dictGetRandomKey(d);
+                ele = dictGetEntryKey(de);
+                elesize = (ele->encoding == REDIS_ENCODING_RAW) ?
+                                (sizeof(*o)+sdslen(ele->ptr)) :
+                                sizeof(*o);
+                ele = dictGetEntryVal(de);
+                elesize = (ele->encoding == REDIS_ENCODING_RAW) ?
+                                (sizeof(*o)+sdslen(ele->ptr)) :
+                                sizeof(*o);
+                asize += (sizeof(struct dictEntry)+elesize)*dictSize(d);
+            }
+        }
+        break;
     }
     return (double)age*log(1+asize);
 }
     }
     return (double)age*log(1+asize);
 }
@@ -8720,13 +8752,18 @@ static void *IOThreadEntryPoint(void *arg) {
 static void spawnIOThread(void) {
     pthread_t thread;
     sigset_t mask, omask;
 static void spawnIOThread(void) {
     pthread_t thread;
     sigset_t mask, omask;
+    int err;
 
     sigemptyset(&mask);
     sigaddset(&mask,SIGCHLD);
     sigaddset(&mask,SIGHUP);
     sigaddset(&mask,SIGPIPE);
     pthread_sigmask(SIG_SETMASK, &mask, &omask);
 
     sigemptyset(&mask);
     sigaddset(&mask,SIGCHLD);
     sigaddset(&mask,SIGHUP);
     sigaddset(&mask,SIGPIPE);
     pthread_sigmask(SIG_SETMASK, &mask, &omask);
-    pthread_create(&thread,&server.io_threads_attr,IOThreadEntryPoint,NULL);
+    while ((err = pthread_create(&thread,&server.io_threads_attr,IOThreadEntryPoint,NULL)) != 0) {
+        redisLog(REDIS_WARNING,"Unable to spawn an I/O thread: %s",
+            strerror(err));
+        usleep(1000000);
+    }
     pthread_sigmask(SIG_SETMASK, &omask, NULL);
     server.io_active_threads++;
 }
     pthread_sigmask(SIG_SETMASK, &omask, NULL);
     server.io_active_threads++;
 }