Commit 4352ff05 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Change defaults:

Make Grace mode the default with 10 seconds (param: default_grace)

Make the thread idle timeout 300 seconds (param: thread_pool_timeout)

Max one new thread per 20 msec (param: thread_pool_add_delay)



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2665 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 9adfd7b0
......@@ -56,6 +56,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
......@@ -66,6 +67,14 @@
static struct hash_slinger *hash;
static double
HSH_Grace(double g)
{
if (isnan(g))
return (double)(params->default_grace);
return (g);
}
/* Precreate an objhead and object for later use */
void
HSH_Prealloc(struct sess *sp)
......@@ -99,6 +108,7 @@ HSH_Prealloc(struct sess *sp)
w->nobj->http->magic = HTTP_MAGIC;
w->nobj->busy = 1;
w->nobj->refcnt = 1;
w->nobj->grace = NAN;
VTAILQ_INIT(&w->nobj->store);
VTAILQ_INIT(&w->nobj->esibits);
VSL_stats->n_object++;
......@@ -221,7 +231,7 @@ HSH_Lookup(struct sess *sp)
break;
/* Remember any matching objects inside their grace period */
if (o->ttl + o->grace >= sp->t_req)
if (o->ttl + HSH_Grace(o->grace) >= sp->t_req)
grace_o = o;
}
......@@ -231,7 +241,7 @@ HSH_Lookup(struct sess *sp)
*/
if (o == NULL && grace_o != NULL &&
grace_o->child != NULL &&
grace_o->ttl + sp->grace >= sp->t_req)
grace_o->ttl + HSH_Grace(sp->grace) >= sp->t_req)
o = grace_o;
if (o != NULL) {
......
......@@ -304,6 +304,7 @@ SES_New(const struct sockaddr *addr, unsigned len)
sp->t_req = NAN;
sp->t_resp = NAN;
sp->t_end = NAN;
sp->grace = NAN;
assert(len <= sp->sockaddrlen);
if (addr != NULL) {
......
......@@ -40,6 +40,7 @@
#include <arpa/inet.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
......@@ -326,6 +327,8 @@ VRT_r_obj_grace(const struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */
if (isnan(sp->obj->grace))
return ((double)params->default_grace);
return (sp->obj->grace);
}
......@@ -446,6 +449,8 @@ double
VRT_r_req_grace(struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
if (isnan(sp->grace))
return ((double)params->default_grace);
return (sp->grace);
}
......
......@@ -156,6 +156,9 @@ struct params {
/* Control diagnostic code */
unsigned diag_bitmap;
/* Default grace period */
unsigned default_grace;
};
extern volatile struct params *params;
......
......@@ -503,7 +503,7 @@ static const struct parspec parspec[] = {
"\n"
"Minimum is 1 second.",
EXPERIMENTAL | DELAYED_EFFECT,
"120", "seconds" },
"300", "seconds" },
{ "thread_pool_purge_delay",
tweak_timeout, &master.wthread_purge_delay, 100, 0,
"Wait this long between purging threads.\n"
......@@ -532,7 +532,7 @@ static const struct parspec parspec[] = {
"Setting this too short increases the risk of worker "
"thread pile-up.\n",
EXPERIMENTAL,
"10", "milliseconds" },
"20", "milliseconds" },
{ "thread_pool_fail_delay",
tweak_timeout, &master.wthread_fail_delay, 100, UINT_MAX,
"Wait at least this long after a failed thread creation "
......@@ -581,6 +581,12 @@ static const struct parspec parspec[] = {
"Minimum is 1024 bytes.",
DELAYED_EFFECT,
"8192", "bytes" },
{ "default_grace", tweak_uint, &master.default_grace, 0, UINT_MAX,
"Default grace period. We will deliver an object "
"this long after it has expired, provided another thread "
"is attempting to get a new copy.",
DELAYED_EFFECT,
"10" "seconds" },
{ "sess_timeout", tweak_timeout, &master.sess_timeout, 0, 0,
"Idle timeout for persistent sessions. "
"If a HTTP request has not been received in this many "
......
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