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
7a808fd8
Commit
7a808fd8
authored
Nov 21, 2017
by
zhaozhao.zz
Browse files
expire & latency: fix the missing latency records generated by expire
parent
2bf8c2c1
Changes
1
Show whitespace changes
Inline
Side-by-side
src/expire.c
View file @
7a808fd8
...
@@ -103,7 +103,7 @@ void activeExpireCycle(int type) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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
);
}
}
/*-----------------------------------------------------------------------------
/*-----------------------------------------------------------------------------
...
...
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