Commit e2b7bb2c authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

The expiry thread caches its "now" timestamp and if there was a lot

of work to do, this timestamp could get behind times, and send the
thread to sleep, despite being behind on work.

Fix this, by updating the timestamp whenever we run out of work.

Add a parameter ("expiry_sleep") to control how long time the thread
will sleep so this can be tuned down on high-load servers.

Inspired by:	sky



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5583 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 0c3b2289
......@@ -226,8 +226,7 @@ EXP_Rearm(const struct object *o)
/*--------------------------------------------------------------------
* This thread monitors the root of the binary heap and whenever an
* object gets close enough, VCL is asked to decide if it should be
* discarded.
* object expires, accounting also for graceability, it is killed.
*/
static void * __match_proto__(void *start_routine(void *))
......@@ -243,11 +242,17 @@ exp_timer(struct sess *sp, void *priv)
Lck_Lock(&exp_mtx);
oc = binheap_root(exp_heap);
CHECK_OBJ_ORNULL(oc, OBJCORE_MAGIC);
/*
* We may have expired so many objects that our timestamp
* got out of date, refresh it and check again.
*/
if (oc != NULL && oc->timer_when > t)
t = TIM_real();
if (oc == NULL || oc->timer_when > t) { /* XXX: > or >= ? */
Lck_Unlock(&exp_mtx);
WSL_Flush(sp->wrk, 0);
WRK_SumStat(sp->wrk);
AZ(sleep(1));
TIM_sleep(params->expiry_sleep);
t = TIM_real();
continue;
}
......
......@@ -178,6 +178,9 @@ struct params {
/* Acceptable clockskew with backends */
unsigned clock_skew;
/* Expiry pacer parameters */
double expiry_sleep;
/* Acceptor pacer parameters */
double acceptor_sleep_max;
double acceptor_sleep_incr;
......
......@@ -549,6 +549,11 @@ static const struct parspec input_parspec[] = {
"seconds, the session is closed.",
0,
"5", "seconds" },
{ "expiry_sleep", tweak_timeout_double, &master.expiry_sleep, 0, 60,
"How long the expiry thread sleeps when there is nothing "
"for it to do. Reduce if your expiry thread gets behind.\n",
0,
"1", "seconds" },
{ "pipe_timeout", tweak_timeout, &master.pipe_timeout, 0, 0,
"Idle timeout for PIPE sessions. "
"If nothing have been received in either direction for "
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment