Mailing List Archive

r2665 - trunk/varnish-cache/bin/varnishd
Author: phk
Date: 2008-06-14 16:26:59 +0200 (Sat, 14 Jun 2008)
New Revision: 2665

Modified:
trunk/varnish-cache/bin/varnishd/cache_hash.c
trunk/varnish-cache/bin/varnishd/cache_session.c
trunk/varnish-cache/bin/varnishd/cache_vrt.c
trunk/varnish-cache/bin/varnishd/heritage.h
trunk/varnish-cache/bin/varnishd/mgt_param.c
Log:
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)



Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c 2008-06-14 14:14:28 UTC (rev 2664)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2008-06-14 14:26:59 UTC (rev 2665)
@@ -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 @@
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 @@
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 @@
*/
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) {

Modified: trunk/varnish-cache/bin/varnishd/cache_session.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_session.c 2008-06-14 14:14:28 UTC (rev 2664)
+++ trunk/varnish-cache/bin/varnishd/cache_session.c 2008-06-14 14:26:59 UTC (rev 2665)
@@ -304,6 +304,7 @@
sp->t_req = NAN;
sp->t_resp = NAN;
sp->t_end = NAN;
+ sp->grace = NAN;

assert(len <= sp->sockaddrlen);
if (addr != NULL) {

Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2008-06-14 14:14:28 UTC (rev 2664)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2008-06-14 14:26:59 UTC (rev 2665)
@@ -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 @@
{
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 @@
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);
}


Modified: trunk/varnish-cache/bin/varnishd/heritage.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/heritage.h 2008-06-14 14:14:28 UTC (rev 2664)
+++ trunk/varnish-cache/bin/varnishd/heritage.h 2008-06-14 14:26:59 UTC (rev 2665)
@@ -156,6 +156,9 @@

/* Control diagnostic code */
unsigned diag_bitmap;
+
+ /* Default grace period */
+ unsigned default_grace;
};

extern volatile struct params *params;

Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-14 14:14:28 UTC (rev 2664)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-14 14:26:59 UTC (rev 2665)
@@ -503,7 +503,7 @@
"\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 @@
"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 @@
"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 "