mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
compute swappability for ziplist encoded lists
This commit is contained in:
parent
cd627d4e78
commit
4e16d8b312
21
redis.c
21
redis.c
@ -9584,8 +9584,10 @@ static double computeObjectSwappability(robj *o) {
|
|||||||
/* actual age can be >= minage, but not < minage. As we use wrapping
|
/* actual age can be >= minage, but not < minage. As we use wrapping
|
||||||
* 21 bit clocks with minutes resolution for the LRU. */
|
* 21 bit clocks with minutes resolution for the LRU. */
|
||||||
time_t minage = abs(server.lruclock - o->lru);
|
time_t minage = abs(server.lruclock - o->lru);
|
||||||
long asize = 0;
|
long asize = 0, elesize;
|
||||||
|
robj *ele;
|
||||||
list *l;
|
list *l;
|
||||||
|
listNode *ln;
|
||||||
dict *d;
|
dict *d;
|
||||||
struct dictEntry *de;
|
struct dictEntry *de;
|
||||||
int z;
|
int z;
|
||||||
@ -9600,18 +9602,19 @@ static double computeObjectSwappability(robj *o) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case REDIS_LIST:
|
case REDIS_LIST:
|
||||||
|
if (o->encoding == REDIS_ENCODING_ZIPLIST) {
|
||||||
|
asize = sizeof(*o)+ziplistSize(o->ptr);
|
||||||
|
} else {
|
||||||
l = o->ptr;
|
l = o->ptr;
|
||||||
listNode *ln = listFirst(l);
|
ln = listFirst(l);
|
||||||
|
|
||||||
asize = sizeof(list);
|
asize = sizeof(list);
|
||||||
if (ln) {
|
if (ln) {
|
||||||
robj *ele = ln->value;
|
ele = ln->value;
|
||||||
long elesize;
|
|
||||||
|
|
||||||
elesize = (ele->encoding == REDIS_ENCODING_RAW) ?
|
elesize = (ele->encoding == REDIS_ENCODING_RAW) ?
|
||||||
(sizeof(*o)+sdslen(ele->ptr)) : sizeof(*o);
|
(sizeof(*o)+sdslen(ele->ptr)) : sizeof(*o);
|
||||||
asize += (sizeof(listNode)+elesize)*listLength(l);
|
asize += (sizeof(listNode)+elesize)*listLength(l);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case REDIS_SET:
|
case REDIS_SET:
|
||||||
case REDIS_ZSET:
|
case REDIS_ZSET:
|
||||||
@ -9621,9 +9624,6 @@ static double computeObjectSwappability(robj *o) {
|
|||||||
asize = sizeof(dict)+(sizeof(struct dictEntry*)*dictSlots(d));
|
asize = sizeof(dict)+(sizeof(struct dictEntry*)*dictSlots(d));
|
||||||
if (z) asize += sizeof(zset)-sizeof(dict);
|
if (z) asize += sizeof(zset)-sizeof(dict);
|
||||||
if (dictSize(d)) {
|
if (dictSize(d)) {
|
||||||
long elesize;
|
|
||||||
robj *ele;
|
|
||||||
|
|
||||||
de = dictGetRandomKey(d);
|
de = dictGetRandomKey(d);
|
||||||
ele = dictGetEntryKey(de);
|
ele = dictGetEntryKey(de);
|
||||||
elesize = (ele->encoding == REDIS_ENCODING_RAW) ?
|
elesize = (ele->encoding == REDIS_ENCODING_RAW) ?
|
||||||
@ -9648,9 +9648,6 @@ static double computeObjectSwappability(robj *o) {
|
|||||||
d = o->ptr;
|
d = o->ptr;
|
||||||
asize = sizeof(dict)+(sizeof(struct dictEntry*)*dictSlots(d));
|
asize = sizeof(dict)+(sizeof(struct dictEntry*)*dictSlots(d));
|
||||||
if (dictSize(d)) {
|
if (dictSize(d)) {
|
||||||
long elesize;
|
|
||||||
robj *ele;
|
|
||||||
|
|
||||||
de = dictGetRandomKey(d);
|
de = dictGetRandomKey(d);
|
||||||
ele = dictGetEntryKey(de);
|
ele = dictGetEntryKey(de);
|
||||||
elesize = (ele->encoding == REDIS_ENCODING_RAW) ?
|
elesize = (ele->encoding == REDIS_ENCODING_RAW) ?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user