Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
d0c64d78
Unverified
Commit
d0c64d78
authored
Jul 25, 2024
by
Moti Cohen
Committed by
GitHub
Jul 25, 2024
Browse files
On active expire, factor maxToExpire based on Hertz (#13439)
parent
82f00f51
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/expire.c
View file @
d0c64d78
...
...
@@ -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
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment