summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2010-03-19 18:02:37 +0100
committerantirez <antirez@gmail.com>2010-03-19 18:02:37 +0100
commita97b9060923da11136798b6c0c71b2da07c0efa7 (patch)
treefe2c4da1a0ce5cfb23e5e7960046bc43c1ff0c22
parentc77169b7e992697d364e886555b613ba8ca27f83 (diff)
downloadredis-a97b9060923da11136798b6c0c71b2da07c0efa7.tar.gz
VM hash type swappability implemented. Handling of failed pthread_create() call.
-rw-r--r--TODO4
-rw-r--r--redis.c39
2 files changed, 39 insertions, 4 deletions
diff --git a/TODO b/TODO
index f9fa8f2af..237fb6499 100644
--- 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)
-* 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.
@@ -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
-* Implement LEN, SUBSTR, PEEK, POKE, SETBIT, GETBIT
+* Implement LEN, PEEK, POKE, SETBIT, GETBIT
VERSION 2.2 TODO (Fault tolerant sharding)
===========================================
diff --git a/redis.c b/redis.c
index 7c0a86956..f272d0036 100644
--- a/redis.c
+++ b/redis.c
@@ -8318,6 +8318,38 @@ static double computeObjectSwappability(robj *o) {
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);
}
@@ -8720,13 +8752,18 @@ static void *IOThreadEntryPoint(void *arg) {
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);
- 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++;
}