From: phk Date: Fri, 8 Sep 2006 06:47:55 +0000 (+0000) Subject: Make the fetchers chunksize a parameter, but keep the default at 128k X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1212ae5d84211d1aa46b05ffc4a74e20cac6559d;p=varnish Make the fetchers chunksize a parameter, but keep the default at 128k git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@949 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_fetch.c b/varnish-cache/bin/varnishd/cache_fetch.c index 966850ea..dbec3008 100644 --- a/varnish-cache/bin/varnishd/cache_fetch.c +++ b/varnish-cache/bin/varnishd/cache_fetch.c @@ -16,16 +16,7 @@ #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; diff --git a/varnish-cache/bin/varnishd/heritage.h b/varnish-cache/bin/varnishd/heritage.h index 1dac9bb3..68336cf8 100644 --- a/varnish-cache/bin/varnishd/heritage.h +++ b/varnish-cache/bin/varnishd/heritage.h @@ -47,6 +47,9 @@ struct params { /* Management hints */ unsigned auto_restart; + + /* Fetcher hints */ + unsigned fetch_chunksize; }; extern struct params *params; diff --git a/varnish-cache/bin/varnishd/mgt_param.c b/varnish-cache/bin/varnishd/mgt_param.c index cd7fe80b..ab480c5b 100644 --- a/varnish-cache/bin/varnishd/mgt_param.c +++ b/varnish-cache/bin/varnishd/mgt_param.c @@ -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 } };