]> err.no Git - varnish/commitdiff
Make the fetchers chunksize a parameter, but keep the default at 128k
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 8 Sep 2006 06:47:55 +0000 (06:47 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 8 Sep 2006 06:47:55 +0000 (06:47 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@949 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_fetch.c
varnish-cache/bin/varnishd/heritage.h
varnish-cache/bin/varnishd/mgt_param.c

index 966850ea99f319a9cfccc38126b016368fc69904..dbec3008f5149b38197a98d4dc1a7233320d4287 100644 (file)
 
 #include "shmlog.h"
 #include "cache.h"
-
-/*
- * Chunked encoding is a hack.  We prefer to have a single chunk or a 
- * few large chunks, and not a terribly long list of small ones.
- * If our stevedore can trim, we alloc big chunks and trim the last one
- * at the end when we know the result.
- *
- * Good testcase: http://www.washingtonpost.com/
- */
-#define CHUNK_PREALLOC         (128 * 1024)
+#include "heritage.h"
 
 /*--------------------------------------------------------------------*/
 
@@ -112,9 +103,9 @@ fetch_chunked(const struct sess *sp, int fd, struct http *hp)
                        /* Get some storage if we don't have any */
                        if (st == NULL || st->len == st->space) {
                                v = u;
-                               if (u < CHUNK_PREALLOC && 
+                               if (u < params->fetch_chunksize && 
                                    stevedore->trim != NULL)
-                                       v = CHUNK_PREALLOC;
+                                       v = params->fetch_chunksize;
                                st = stevedore->alloc(stevedore, v);
                                XXXAN(st->stevedore);
                                TAILQ_INSERT_TAIL(&sp->obj->store, st, list);
@@ -189,7 +180,7 @@ fetch_eof(const struct sess *sp, int fd, struct http *hp)
        st = NULL;
        while (1) {
                if (v == 0) {
-                       st = stevedore->alloc(stevedore, CHUNK_PREALLOC);
+                       st = stevedore->alloc(stevedore, params->fetch_chunksize);
                        XXXAN(st->stevedore);
                        TAILQ_INSERT_TAIL(&sp->obj->store, st, list);
                        p = st->ptr + st->len;
index 1dac9bb3f9688a09060b8a483ab949918f88c7d9..68336cf871c73fb1846d5f37b64346e97c5da6e1 100644 (file)
@@ -47,6 +47,9 @@ struct params {
 
        /* Management hints */
        unsigned                auto_restart;
+
+       /* Fetcher hints */
+       unsigned                fetch_chunksize;
 };
 
 extern struct params *params;
index cd7fe80b473ada05e9a0e333d7f59679950a76ee..ab480c5b72faf8e05beba10afab1f44bfa841dec 100644 (file)
@@ -190,6 +190,23 @@ tweak_auto_restart(struct cli *cli, struct parspec *par, const char *arg)
 
 /*--------------------------------------------------------------------*/
 
+static void
+tweak_fetch_chunksize(struct cli *cli, struct parspec *par, const char *arg)
+{
+       unsigned u;
+
+       (void)par;
+       if (arg != NULL) {
+               u = strtoul(arg, NULL, 0);
+               params->fetch_chunksize = u;
+       }
+       if (cli == NULL)
+               return;
+       cli_out(cli, "%u [kb]\n", params->fetch_chunksize);
+}
+
+/*--------------------------------------------------------------------*/
+
 /*
  * Make sure to end all lines with either a space or newline of the
  * formatting will go haywire.
@@ -257,6 +274,9 @@ static struct parspec parspec[] = {
                "Restart child process automatically if it dies. "
                "1 = yes, 0 = no.\n"
                "Default is 1. ", "1" },
+       { "fetch_chunksize", tweak_fetch_chunksize,
+               "The default chunksize used by fetcher.\n"
+               "Default is 128 kilobytes. ", "128" },
        { NULL, NULL, NULL }
 };