Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
4e16d8b3
Commit
4e16d8b3
authored
Jun 07, 2010
by
Pieter Noordhuis
Browse files
compute swappability for ziplist encoded lists
parent
cd627d4e
Changes
1
Show whitespace changes
Inline
Side-by-side
redis.c
View file @
4e16d8b3
...
@@ -9584,8 +9584,10 @@ static double computeObjectSwappability(robj *o) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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
)
?
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment