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
e8ceba4e
Commit
e8ceba4e
authored
Nov 18, 2019
by
antirez
Browse files
Expire cycle: set a buckets limit as well.
parent
2ab51a64
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/expire.c
View file @
e8ceba4e
...
@@ -237,8 +237,18 @@ void activeExpireCycle(int type) {
...
@@ -237,8 +237,18 @@ void activeExpireCycle(int type) {
/* Here we access the low level representation of the hash table
/* Here we access the low level representation of the hash table
* for speed concerns: this makes this code coupled with dict.c,
* for speed concerns: this makes this code coupled with dict.c,
* but it hardly changed in ten years. */
* but it hardly changed in ten years.
while
(
sampled
<
num
)
{
*
* Note that certain places of the hash table may be empty,
* so we want also a stop condition about the number of
* buckets that we scanned. However scanning for free buckets
* is very fast: we are in the cache line scanning a sequential
* array of NULL pointers, so we can scan a lot more buckets
* than keys in the same time. */
long
max_buckets
=
num
*
20
;
long
checked_buckets
=
0
;
while
(
sampled
<
num
&&
checked_buckets
<
max_buckets
)
{
for
(
int
table
=
0
;
table
<
2
;
table
++
)
{
for
(
int
table
=
0
;
table
<
2
;
table
++
)
{
if
(
table
==
1
&&
!
dictIsRehashing
(
db
->
expires
))
break
;
if
(
table
==
1
&&
!
dictIsRehashing
(
db
->
expires
))
break
;
...
@@ -248,6 +258,7 @@ void activeExpireCycle(int type) {
...
@@ -248,6 +258,7 @@ void activeExpireCycle(int type) {
long
long
ttl
;
long
long
ttl
;
/* Scan the current bucket of the current table. */
/* Scan the current bucket of the current table. */
checked_buckets
++
;
while
(
de
)
{
while
(
de
)
{
/* Get the next entry now since this entry may get
/* Get the next entry now since this entry may get
* deleted. */
* deleted. */
...
...
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