]> err.no Git - varnish/commitdiff
Do stats on sendfile/write split.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 11 Sep 2006 08:42:35 +0000 (08:42 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 11 Sep 2006 08:42:35 +0000 (08:42 +0000)
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

varnish-cache/bin/varnishd/cache_response.c
varnish-cache/bin/varnishd/heritage.h
varnish-cache/bin/varnishd/mgt_param.c
varnish-cache/include/stat_field.h

index a386427249ae48d8d360766600a7ee195244cc00..f0dcacea0a0b04339ba3c1f1c9835cd56ca3ad67 100644 (file)
@@ -8,6 +8,7 @@
 #include <sys/time.h>
 
 #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);
index 68336cf871c73fb1846d5f37b64346e97c5da6e1..1997118b27309b695114157d03cf11f62dca983f 100644 (file)
@@ -50,6 +50,9 @@ struct params {
 
        /* Fetcher hints */
        unsigned                fetch_chunksize;
+
+       /* Sendfile object minimum size */
+       unsigned                sendfile_threshold;
 };
 
 extern struct params *params;
index ab480c5b72faf8e05beba10afab1f44bfa841dec..1ce7b213ab6462d95a9cd160d28578ad9f1bbcc5 100644 (file)
@@ -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 }
 };
 
index 68292658883afb8dfe021a0b3e6a7b636bf68495..e59365c3cafe484f3020801737e08c469223ad21 100644 (file)
@@ -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")