add lookup limit to active subkey expire

Former-commit-id: 5d6da23108401b3b554eaec5d7c78aa0950a28f2
This commit is contained in:
Malavan 2021-05-04 22:28:03 +00:00
parent 6312005640
commit 9a2d6cbad2

View File

@ -68,7 +68,7 @@ void activeExpireCycleExpireFullKey(redisDb *db, const char *key) {
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
int activeExpireCycleExpire(redisDb *db, expireEntry &e, long long now, int &tried) { int activeExpireCycleExpire(redisDb *db, expireEntry &e, long long now, size_t &tried) {
if (!e.FFat()) if (!e.FFat())
{ {
activeExpireCycleExpireFullKey(db, e.key()); activeExpireCycleExpireFullKey(db, e.key());
@ -154,7 +154,7 @@ int activeExpireCycleExpire(redisDb *db, expireEntry &e, long long now, int &tri
pfat->popfrontExpireEntry(); pfat->popfrontExpireEntry();
fTtlChanged = true; fTtlChanged = true;
if ((tried % ACTIVE_EXPIRE_CYCLE_LOOKUPS_PER_LOOP) == 0) { if ((tried % ACTIVE_EXPIRE_CYCLE_LOOKUPS_PER_LOOP) == 0) {
return deleted; break;
} }
} }
@ -382,8 +382,8 @@ void activeExpireCycleCore(int type) {
continue; continue;
} }
int expired = 0; size_t expired = 0;
int tried = 0; size_t tried = 0;
long long check = ACTIVE_EXPIRE_CYCLE_FAST_DURATION; // assume a check is roughly 1us. It isn't but good enough long long check = ACTIVE_EXPIRE_CYCLE_FAST_DURATION; // assume a check is roughly 1us. It isn't but good enough
db->expireitr = db->setexpire->enumerate(db->expireitr, now, [&](expireEntry &e) __attribute__((always_inline)) { db->expireitr = db->setexpire->enumerate(db->expireitr, now, [&](expireEntry &e) __attribute__((always_inline)) {
if (e.when() < now) if (e.when() < now)
@ -497,7 +497,7 @@ void expireSlaveKeys(void) {
if (itr != db->setexpire->end()) if (itr != db->setexpire->end())
{ {
if (itr->when() < start) { if (itr->when() < start) {
int tried = 0; size_t tried = 0;
expired = activeExpireCycleExpire(g_pserver->db+dbid,*itr,start,tried); expired = activeExpireCycleExpire(g_pserver->db+dbid,*itr,start,tried);
} }
} }