mirror of https://mirror.osredm.com/root/redis.git
On active expire, factor maxToExpire based on Hertz (#13439)
This commit is contained in:
parent
82f00f5179
commit
d0c64d78d4
|
@ -94,7 +94,8 @@ int activeExpireCycleTryExpire(redisDb *db, dictEntry *de, long long now) {
|
|||
#define ACTIVE_EXPIRE_CYCLE_SLOW_TIME_PERC 25 /* Max % of CPU to use. */
|
||||
#define ACTIVE_EXPIRE_CYCLE_ACCEPTABLE_STALE 10 /* % of stale keys after which
|
||||
we do extra efforts. */
|
||||
#define HFE_ACTIVE_EXPIRE_CYCLE_FIELDS 1000
|
||||
|
||||
#define HFE_DB_BASE_ACTIVE_EXPIRE_FIELDS_PER_SEC 10000
|
||||
|
||||
/* Data used by the expire dict scan callback. */
|
||||
typedef struct {
|
||||
|
@ -151,8 +152,6 @@ static inline void activeExpireHashFieldCycle(int type) {
|
|||
static uint64_t activeExpirySequence = 0;
|
||||
/* Threshold for adjusting maxToExpire */
|
||||
const uint32_t EXPIRED_FIELDS_TH = 1000000;
|
||||
/* Maximum number of fields to actively expire in a single call */
|
||||
uint32_t maxToExpire = HFE_ACTIVE_EXPIRE_CYCLE_FIELDS;
|
||||
|
||||
redisDb *db = server.db + currentDb;
|
||||
|
||||
|
@ -163,6 +162,9 @@ static inline void activeExpireHashFieldCycle(int type) {
|
|||
return;
|
||||
}
|
||||
|
||||
/* Maximum number of fields to actively expire on a single call */
|
||||
uint32_t maxToExpire = HFE_DB_BASE_ACTIVE_EXPIRE_FIELDS_PER_SEC / server.hz;
|
||||
|
||||
/* If running for a while and didn't manage to active-expire all expired fields of
|
||||
* currentDb (i.e. activeExpirySequence becomes significant) then adjust maxToExpire */
|
||||
if ((activeExpirySequence > EXPIRED_FIELDS_TH) && (type == ACTIVE_EXPIRE_CYCLE_SLOW)) {
|
||||
|
|
Loading…
Reference in New Issue