]> err.no Git - varnish/commitdiff
Change defaults:
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 14 Jun 2008 14:26:59 +0000 (14:26 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 14 Jun 2008 14:26:59 +0000 (14:26 +0000)
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: svn+ssh://projects.linpro.no/svn/varnish/trunk@2665 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_hash.c
varnish-cache/bin/varnishd/cache_session.c
varnish-cache/bin/varnishd/cache_vrt.c
varnish-cache/bin/varnishd/heritage.h
varnish-cache/bin/varnishd/mgt_param.c

index 439e0a2125d7730248c22c109fff3e24b3ee2467..4f736ae22343213eccc341c6c0e499ac0ac87e68 100644 (file)
@@ -56,6 +56,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <math.h>
 #include <string.h>
 #include <sys/types.h>
 #include <fcntl.h>
 
 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) {
index 53511e44e5210e23dd6ecf500732c1c515a4579b..268904a7f1906a1c3ee328adde5b1b3177869164 100644 (file)
@@ -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) {
index b15d32774c3fea847d8a5360c8ec6ddfe6bbcfe7..d0f76d967a7d8f7b6e11710f2817264c6f7a8dad 100644 (file)
@@ -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);
 }
 
index 694b5ebba9e78fa10840806383cf4856da7202ec..41d8a73de1502966b2572870af92a720e961f1b7 100644 (file)
@@ -156,6 +156,9 @@ struct params {
 
        /* Control diagnostic code */
        unsigned                diag_bitmap;
+
+       /* Default grace period */
+       unsigned                default_grace;
 };
 
 extern volatile struct params *params;
index e6e13f85825a4116baef8db67a1f1d3c0d3ebab2..091c30abc45f79e0661a1562bacebd0719cd331a 100644 (file)
@@ -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 "