27610 Commits

Author SHA1 Message Date
antirez
92ab77f8d5 redis-benchmark: replace snprintf()+memcpy with faster code.
This change was profiler-driven, but the actual effect is hard to
measure in real-world redis benchmark runs.
2013-08-08 14:33:14 +02:00
Salvatore Sanfilippo
d366fdf75e Merge pull request #1234 from badboy/patch-2
Little typo
2013-08-07 07:08:04 -07:00
Salvatore Sanfilippo
de698798bc Merge pull request #1234 from badboy/patch-2
Little typo
2013-08-07 07:08:04 -07:00
Jan-Erik Rediger
05b9bfc79b Little typo 2013-08-07 16:05:09 +02:00
Jan-Erik Rediger
74c0af21f5 Little typo 2013-08-07 16:05:09 +02:00
antirez
7ab3495410 redis-benchmark: fix memory leak introduced by 22d35c6 2013-08-07 16:00:18 +02:00
antirez
36a0947185 redis-benchmark: fix memory leak introduced by 346256f 2013-08-07 16:00:18 +02:00
antirez
22d35c646c redis-benchmark: max pipeline length hardcoded limit removed. 2013-08-07 15:58:58 +02:00
antirez
346256f933 redis-benchmark: max pipeline length hardcoded limit removed. 2013-08-07 15:58:58 +02:00
antirez
e053e250c9 redis-benchmark: fix db selection when :rand: feature is used. 2013-08-06 19:01:54 +02:00
antirez
6cbfdd9520 redis-benchmark: fix db selection when :rand: feature is used. 2013-08-06 19:01:54 +02:00
antirez
09c76e6800 redis-benchmark: ability to SELECT a specifid db number. 2013-08-06 18:50:54 +02:00
antirez
d52c9b6cdb redis-benchmark: ability to SELECT a specifid db number. 2013-08-06 18:50:54 +02:00
antirez
623ad22fa8 Add per-db average TTL information in INFO output.
Example:

db0:keys=221913,expires=221913,avg_ttl=655

The algorithm uses a running average with only two samples (current and
previous). Keys found to be expired are considered at TTL zero even if
the actual TTL can be negative.

The TTL is reported in milliseconds.
2013-08-06 15:00:43 +02:00
antirez
112fa47978 Add per-db average TTL information in INFO output.
Example:

db0:keys=221913,expires=221913,avg_ttl=655

The algorithm uses a running average with only two samples (current and
previous). Keys found to be expired are considered at TTL zero even if
the actual TTL can be negative.

The TTL is reported in milliseconds.
2013-08-06 15:00:43 +02:00
antirez
67b4704bc6 activeExpireCycle(): fix about fast cycle early start.
We don't want to repeat a fast cycle too soon, the previous code was
broken, we need to wait two times the period *since* the start of the
previous cycle in order to avoid there is an even space between cycles:

.-> start                   .-> second start
|                           |
+-------------+-------------+--------------+
| first cycle |    pause    | second cycle |
+-------------+-------------+--------------+

The second and first start must be PERIOD*2 useconds apart hence the *2
in the new code.
2013-08-06 12:59:04 +02:00
antirez
4befe73b60 activeExpireCycle(): fix about fast cycle early start.
We don't want to repeat a fast cycle too soon, the previous code was
broken, we need to wait two times the period *since* the start of the
previous cycle in order to avoid there is an even space between cycles:

.-> start                   .-> second start
|                           |
+-------------+-------------+--------------+
| first cycle |    pause    | second cycle |
+-------------+-------------+--------------+

The second and first start must be PERIOD*2 useconds apart hence the *2
in the new code.
2013-08-06 12:59:04 +02:00
antirez
1dd670c34b Some activeExpireCycle() refactoring. 2013-08-06 12:55:49 +02:00
antirez
6500fabfb8 Some activeExpireCycle() refactoring. 2013-08-06 12:55:49 +02:00
antirez
8d70078b45 Remove dead code and fix comments for new expire code. 2013-08-06 12:36:13 +02:00
antirez
d398f38879 Remove dead code and fix comments for new expire code. 2013-08-06 12:36:13 +02:00
antirez
f526102801 Darft #2 for key collection algo: more improvements.
This commit makes the fast collection cycle time configurable, at
the same time it does not allow to run a new fast collection cycle
for the same amount of time as the max duration of the fast
collection cycle.
2013-08-05 16:14:28 +02:00
antirez
66a26471dc Darft #2 for key collection algo: more improvements.
This commit makes the fast collection cycle time configurable, at
the same time it does not allow to run a new fast collection cycle
for the same amount of time as the max duration of the fast
collection cycle.
2013-08-05 16:14:28 +02:00
antirez
db3bbb9006 Draft #1 of a new expired keys collection algorithm.
The main idea here is that when we are no longer to expire keys at the
rate the are created, we can't block more in the normal expire cycle as
this would result in too big latency spikes.

For this reason the commit introduces a "fast" expire cycle that does
not run for more than 1 millisecond but is called in the beforeSleep()
hook of the event loop, so much more often, and with a frequency bound
to the frequency of executed commnads.

The fast expire cycle is only called when the standard expiration
algorithm runs out of time, that is, consumed more than
REDIS_EXPIRELOOKUPS_TIME_PERC of CPU in a given cycle without being able
to take the number of already expired keys that are yet not collected
to a number smaller than 25% of the number of keys.

You can test this commit with different loads, but a simple way is to
use the following:

Extreme load with pipelining:

redis-benchmark -r 100000000 -n 100000000  \
        -P 32 set ele:rand:000000000000 foo ex 2

Remove the -P32 in order to avoid the pipelining for a more real-world
load.

In another terminal tab you can monitor the Redis behavior with:

redis-cli -i 0.1 -r -1 info keyspace

and

redis-cli --latency-history

Note: this commit will make Redis printing a lot of debug messages, it
is not a good idea to use it in production.
2013-08-05 12:05:22 +02:00
antirez
b09ea1bd90 Draft #1 of a new expired keys collection algorithm.
The main idea here is that when we are no longer to expire keys at the
rate the are created, we can't block more in the normal expire cycle as
this would result in too big latency spikes.

For this reason the commit introduces a "fast" expire cycle that does
not run for more than 1 millisecond but is called in the beforeSleep()
hook of the event loop, so much more often, and with a frequency bound
to the frequency of executed commnads.

The fast expire cycle is only called when the standard expiration
algorithm runs out of time, that is, consumed more than
REDIS_EXPIRELOOKUPS_TIME_PERC of CPU in a given cycle without being able
to take the number of already expired keys that are yet not collected
to a number smaller than 25% of the number of keys.

You can test this commit with different loads, but a simple way is to
use the following:

Extreme load with pipelining:

redis-benchmark -r 100000000 -n 100000000  \
        -P 32 set ele:rand:000000000000 foo ex 2

Remove the -P32 in order to avoid the pipelining for a more real-world
load.

In another terminal tab you can monitor the Redis behavior with:

redis-cli -i 0.1 -r -1 info keyspace

and

redis-cli --latency-history

Note: this commit will make Redis printing a lot of debug messages, it
is not a good idea to use it in production.
2013-08-05 12:05:22 +02:00
antirez
1b26e3e1fa Test: regression test for issue #1221. 2013-07-29 17:39:28 +02:00
antirez
cd0ea1f202 Test: regression test for issue #1221. 2013-07-29 17:39:28 +02:00
antirez
9efbe0dca0 Fix replicationFeedSlaves() off-by-one bug.
This fixes issue #1221.
2013-07-28 12:49:34 +02:00
antirez
c151eb6d92 Fix replicationFeedSlaves() off-by-one bug.
This fixes issue #1221.
2013-07-28 12:49:34 +02:00
antirez
9453949f8b Remove dead variable bothsds from object.c.
Thanks to @run and @badboy for spotting this.
Triva: clang was not able to provide me a warning about that when
compiling.

This closes #1024 and #1207, committing the change myself as the pull
requests no longer apply cleanly after other changes to the same
function.
2013-07-28 11:00:09 +02:00
antirez
bf56948fd0 Remove dead variable bothsds from object.c.
Thanks to @run and @badboy for spotting this.
Triva: clang was not able to provide me a warning about that when
compiling.

This closes #1024 and #1207, committing the change myself as the pull
requests no longer apply cleanly after other changes to the same
function.
2013-07-28 11:00:09 +02:00
antirez
b55bcdd3ab Use latest sds.c in the hiredis library under deps. 2013-07-25 10:32:19 +02:00
antirez
320fa02b9b Use latest sds.c in the hiredis library under deps. 2013-07-25 10:32:19 +02:00
Allan
74ff4fc728 fixed initServer fail while having no IPv6 nor IPv4 2013-07-25 15:36:00 +08:00
Allan
a0e986d7f2 fixed initServer fail while having no IPv6 nor IPv4 2013-07-25 15:36:00 +08:00
Allan
d3736ba400 fixed initServer failed if no IPV4 or no IPV6 2013-07-25 15:28:33 +08:00
Allan
cba7a4e69a fixed initServer failed if no IPV4 or no IPV6 2013-07-25 15:28:33 +08:00
antirez
31fe0202e4 Ignore sdsrange return value. 2013-07-24 18:59:54 +02:00
antirez
3ccc17a4a5 Ignore sdsrange return value. 2013-07-24 18:59:54 +02:00
Allan
f1be75e5d0 fixed bug issue of #1213 2013-07-24 21:34:55 +08:00
Allan
1e7cff23b3 fixed bug issue of #1213 2013-07-24 21:34:55 +08:00
antirez
fc11a99390 sdsrange() does not need to return a value.
Actaully the string is modified in-place and a reallocation is never
needed, so there is no need to return the new sds string pointer as
return value of the function, that is now just "void".
2013-07-24 11:21:39 +02:00
antirez
6ea8e0949c sdsrange() does not need to return a value.
Actaully the string is modified in-place and a reallocation is never
needed, so there is no need to return the new sds string pointer as
return value of the function, that is now just "void".
2013-07-24 11:21:39 +02:00
antirez
a184ff7d0e Inline protocol improved to accept quoted strings. 2013-07-24 10:37:55 +02:00
antirez
75b760a72d Inline protocol improved to accept quoted strings. 2013-07-24 10:37:55 +02:00
antirez
02a22c9be1 Every function inside sds.c is now commented. 2013-07-23 16:35:55 +02:00
antirez
076c2623ac Every function inside sds.c is now commented. 2013-07-23 16:35:55 +02:00
antirez
be2e9f4f47 getStringObjectSdsUsedMemory() function added.
Now that EMBSTR encoding exists we calculate the amount of memory used
by the SDS part of a Redis String object in two different ways:

1) For raw string object, the size of the allocation is considered.
2) For embstr objects, the length of the string itself is used.

The new function takes care of this logic.
2013-07-23 11:50:17 +02:00
antirez
ec7f480e11 getStringObjectSdsUsedMemory() function added.
Now that EMBSTR encoding exists we calculate the amount of memory used
by the SDS part of a Redis String object in two different ways:

1) For raw string object, the size of the allocation is considered.
2) For embstr objects, the length of the string itself is used.

The new function takes care of this logic.
2013-07-23 11:50:17 +02:00
antirez
995cb581a9 Test: regression test for issue #1208. 2013-07-22 23:40:48 +02:00