提交 d54e373b 编写于 作者: A antirez

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.
上级 500155b9
......@@ -671,6 +671,7 @@ int activeExpireCycleTryExpire(redisDb *db, struct dictEntry *de, long long now)
* more incrementally from the beforeSleep() function of the event loop. */
#define EXPIRED_HISTORY_LEN 10
#define EXPIRE_FAST_CYCLE_DURATION 1000
void activeExpireCycle(int fast) {
/* This function has some global state in order to continue the work
......@@ -681,6 +682,7 @@ void activeExpireCycle(int fast) {
unsigned int j, iteration = 0;
unsigned int dbs_per_call = REDIS_DBCRON_DBS_PER_CALL;
long long start = ustime(), timelimit;
static long long last_fast_cycle = 0;
#if 0
static int expired_history[EXPIRED_HISTORY_LEN];
......@@ -688,7 +690,17 @@ void activeExpireCycle(int fast) {
static int expired_perc_avg = 0;
#endif
if (fast && !timelimit_exit) return;
if (fast) {
/* Don't start a fast cycle if the previous cycle did not exited
* for time limt. Also don't repeat a fast cycle for the same period
* as the fast cycle total duration itself. */
if (!timelimit_exit) return;
if (start < last_fast_cycle + EXPIRE_FAST_CYCLE_DURATION) {
printf("CANT START A FAST CYCLE\n");
return;
}
last_fast_cycle = start;
}
#if 0
if (fast) {
......@@ -725,7 +737,7 @@ void activeExpireCycle(int fast) {
timelimit_exit = 0;
if (timelimit <= 0) timelimit = 1;
if (fast) timelimit = 1000; /* 1 millisecond. */
if (fast) timelimit = EXPIRE_FAST_CYCLE_DURATION; /* in microseconds. */
for (j = 0; j < dbs_per_call; j++) {
int expired;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册