]> git.saurik.com Git - redis.git/commit
Redis timer interrupt frequency configurable as REDIS_HZ.
authorantirez <antirez@gmail.com>
Sun, 13 May 2012 14:40:29 +0000 (16:40 +0200)
committerantirez <antirez@gmail.com>
Sun, 13 May 2012 14:40:29 +0000 (16:40 +0200)
commit94343492361a04301a48fc56490d6113ff97aba9
treef9523d7d14944c645fe35a5a9a7ac70243dc2648
parentf333788fbcaf67fa97c509f0f61d557b6669b1fe
Redis timer interrupt frequency configurable as REDIS_HZ.

Redis uses a function called serverCron() that is very similar to the
timer interrupt of an operating system. This function is used to handle
a number of asynchronous things, like active expired keys collection,
clients timeouts, update of statistics, things related to the cluster
and replication, triggering of BGSAVE and AOF rewrite process, and so
forth.

In the past the timer was called 1 time per second. At some point it was
raised to 10 times per second, but it still was fixed and could not be
changed even at compile time, because different functions called from
serverCron() assumed a given fixed frequency.

This commmit makes the frequency configurable, so that it is simpler to
pick a good tradeoff between overhead of this function (that is usually
very small) and the responsiveness of Redis during a few critical
circumstances where a lot of work is done inside the timer.

An example of such a critical condition is mass-expire of a lot of keys
in the same second. Up to a given percentage of CPU time is used to
perform expired keys collection per expire cylce. Now changing the
REDIS_HZ macro it is possible to do less work but more times per second
in order to block the server for less time.

If this patch will work well in our tests it will enter Redis 2.6-final.
src/redis.c
src/redis.h