mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
expire & latency: fix the missing latency records generated by expire
This commit is contained in:
parent
2bf8c2c130
commit
7a808fd8a7
19
src/expire.c
19
src/expire.c
@ -103,7 +103,7 @@ void activeExpireCycle(int type) {
|
|||||||
|
|
||||||
int j, iteration = 0;
|
int j, iteration = 0;
|
||||||
int dbs_per_call = CRON_DBS_PER_CALL;
|
int dbs_per_call = CRON_DBS_PER_CALL;
|
||||||
long long start = ustime(), timelimit;
|
long long start = ustime(), timelimit, elapsed;
|
||||||
|
|
||||||
/* When clients are paused the dataset should be static not just from the
|
/* When clients are paused the dataset should be static not just from the
|
||||||
* POV of clients not being able to write, but also from the POV of
|
* POV of clients not being able to write, but also from the POV of
|
||||||
@ -140,7 +140,7 @@ void activeExpireCycle(int type) {
|
|||||||
if (type == ACTIVE_EXPIRE_CYCLE_FAST)
|
if (type == ACTIVE_EXPIRE_CYCLE_FAST)
|
||||||
timelimit = ACTIVE_EXPIRE_CYCLE_FAST_DURATION; /* in microseconds. */
|
timelimit = ACTIVE_EXPIRE_CYCLE_FAST_DURATION; /* in microseconds. */
|
||||||
|
|
||||||
for (j = 0; j < dbs_per_call; j++) {
|
for (j = 0; j < dbs_per_call && timelimit_exit == 0; j++) {
|
||||||
int expired;
|
int expired;
|
||||||
redisDb *db = server.db+(current_db % server.dbnum);
|
redisDb *db = server.db+(current_db % server.dbnum);
|
||||||
|
|
||||||
@ -155,6 +155,7 @@ void activeExpireCycle(int type) {
|
|||||||
unsigned long num, slots;
|
unsigned long num, slots;
|
||||||
long long now, ttl_sum;
|
long long now, ttl_sum;
|
||||||
int ttl_samples;
|
int ttl_samples;
|
||||||
|
iteration++;
|
||||||
|
|
||||||
/* If there is nothing to expire try next DB ASAP. */
|
/* If there is nothing to expire try next DB ASAP. */
|
||||||
if ((num = dictSize(db->expires)) == 0) {
|
if ((num = dictSize(db->expires)) == 0) {
|
||||||
@ -207,18 +208,20 @@ void activeExpireCycle(int type) {
|
|||||||
/* We can't block forever here even if there are many keys to
|
/* We can't block forever here even if there are many keys to
|
||||||
* expire. So after a given amount of milliseconds return to the
|
* expire. So after a given amount of milliseconds return to the
|
||||||
* caller waiting for the other active expire cycle. */
|
* caller waiting for the other active expire cycle. */
|
||||||
iteration++;
|
|
||||||
if ((iteration & 0xf) == 0) { /* check once every 16 iterations. */
|
if ((iteration & 0xf) == 0) { /* check once every 16 iterations. */
|
||||||
long long elapsed = ustime()-start;
|
elapsed = ustime()-start;
|
||||||
|
if (elapsed > timelimit) {
|
||||||
latencyAddSampleIfNeeded("expire-cycle",elapsed/1000);
|
timelimit_exit = 1;
|
||||||
if (elapsed > timelimit) timelimit_exit = 1;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (timelimit_exit) return;
|
|
||||||
/* We don't repeat the cycle if there are less than 25% of keys
|
/* We don't repeat the cycle if there are less than 25% of keys
|
||||||
* found expired in the current DB. */
|
* found expired in the current DB. */
|
||||||
} while (expired > ACTIVE_EXPIRE_CYCLE_LOOKUPS_PER_LOOP/4);
|
} while (expired > ACTIVE_EXPIRE_CYCLE_LOOKUPS_PER_LOOP/4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
elapsed = ustime()-start;
|
||||||
|
latencyAddSampleIfNeeded("expire-cycle",elapsed/1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------
|
/*-----------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user