From: phk Date: Mon, 11 Sep 2006 08:42:35 +0000 (+0000) Subject: Do stats on sendfile/write split. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a60bb1ee8d538973f049d694e6e9f955448136c0;p=varnish Do stats on sendfile/write split. Add param for minimum size of object before we will sendfile it. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@951 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_response.c b/varnish-cache/bin/varnishd/cache_response.c index a3864272..f0dcacea 100644 --- a/varnish-cache/bin/varnishd/cache_response.c +++ b/varnish-cache/bin/varnishd/cache_response.c @@ -8,6 +8,7 @@ #include #include "shmlog.h" +#include "heritage.h" #include "cache.h" /*--------------------------------------------------------------------*/ @@ -232,12 +233,15 @@ RES_WriteObj(struct sess *sp) * XXX: engaging sendfile for small objects. * XXX: Should use getpagesize() ? */ - if (st->fd >= 0 && st->len >= 8192) { + if (st->fd >= 0 && + st->len >= params->sendfile_threshold) { + VSL_stats->n_objsendfile++; WRK_Sendfile(sp->wrk, st->fd, st->where, st->len); continue; } #endif /* HAVE_SENDFILE */ + VSL_stats->n_objwrite++; WRK_Write(sp->wrk, st->ptr, st->len); } assert(u == sp->obj->len); diff --git a/varnish-cache/bin/varnishd/heritage.h b/varnish-cache/bin/varnishd/heritage.h index 68336cf8..1997118b 100644 --- a/varnish-cache/bin/varnishd/heritage.h +++ b/varnish-cache/bin/varnishd/heritage.h @@ -50,6 +50,9 @@ struct params { /* Fetcher hints */ unsigned fetch_chunksize; + + /* Sendfile object minimum size */ + unsigned sendfile_threshold; }; extern struct params *params; diff --git a/varnish-cache/bin/varnishd/mgt_param.c b/varnish-cache/bin/varnishd/mgt_param.c index ab480c5b..1ce7b213 100644 --- a/varnish-cache/bin/varnishd/mgt_param.c +++ b/varnish-cache/bin/varnishd/mgt_param.c @@ -205,6 +205,25 @@ tweak_fetch_chunksize(struct cli *cli, struct parspec *par, const char *arg) cli_out(cli, "%u [kb]\n", params->fetch_chunksize); } +#ifdef HAVE_SENDFILE +/*--------------------------------------------------------------------*/ + +static void +tweak_sendfile_threshold(struct cli *cli, struct parspec *par, const char *arg) +{ + unsigned u; + + (void)par; + if (arg != NULL) { + u = strtoul(arg, NULL, 0); + params->sendfile_threshold = u; + } + if (cli == NULL) + return; + cli_out(cli, "%u [bytes]\n", params->sendfile_threshold); +} +#endif /* HAVE_SENDFILE */ + /*--------------------------------------------------------------------*/ /* @@ -277,6 +296,11 @@ static struct parspec parspec[] = { { "fetch_chunksize", tweak_fetch_chunksize, "The default chunksize used by fetcher.\n" "Default is 128 kilobytes. ", "128" }, +#ifdef HAVE_SENDFILE + { "sendfile_threshold", tweak_sendfile_threshold, + "The minimum size of objects transmitted with sendfile.\n" + "Default is 8192 bytes.", "8192" }, +#endif /* HAVE_SENDFILE */ { NULL, NULL, NULL } }; diff --git a/varnish-cache/include/stat_field.h b/varnish-cache/include/stat_field.h index 68292658..e59365c3 100644 --- a/varnish-cache/include/stat_field.h +++ b/varnish-cache/include/stat_field.h @@ -33,6 +33,9 @@ MAC_STAT(n_deathrow, uint64_t, "u", "N objects on deathrow") MAC_STAT(losthdr, uint64_t, "u", "HTTP header overflows") +MAC_STAT(n_objsendfile, uint64_t, "u", "Objects sent with sendfile") +MAC_STAT(n_objwrite, uint64_t, "u", "Objects sent with write") + MAC_STAT(s_sess, uint64_t, "u", "Total Sessions") MAC_STAT(s_req, uint64_t, "u", "Total Requests") MAC_STAT(s_pipe, uint64_t, "u", "Total pipe")