r951 - in trunk/varnish-cache: bin/varnishd include
phk at projects.linpro.no
phk at projects.linpro.no
Mon Sep 11 10:42:35 CEST 2006
Author: phk
Date: 2006-09-11 10:42:35 +0200 (Mon, 11 Sep 2006)
New Revision: 951
Modified:
trunk/varnish-cache/bin/varnishd/cache_response.c
trunk/varnish-cache/bin/varnishd/heritage.h
trunk/varnish-cache/bin/varnishd/mgt_param.c
trunk/varnish-cache/include/stat_field.h
Log:
Do stats on sendfile/write split.
Add param for minimum size of object before we will sendfile it.
Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c 2006-09-10 22:23:59 UTC (rev 950)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c 2006-09-11 08:42:35 UTC (rev 951)
@@ -8,6 +8,7 @@
#include <sys/time.h>
#include "shmlog.h"
+#include "heritage.h"
#include "cache.h"
/*--------------------------------------------------------------------*/
@@ -232,12 +233,15 @@
* 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);
Modified: trunk/varnish-cache/bin/varnishd/heritage.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/heritage.h 2006-09-10 22:23:59 UTC (rev 950)
+++ trunk/varnish-cache/bin/varnishd/heritage.h 2006-09-11 08:42:35 UTC (rev 951)
@@ -50,6 +50,9 @@
/* Fetcher hints */
unsigned fetch_chunksize;
+
+ /* Sendfile object minimum size */
+ unsigned sendfile_threshold;
};
extern struct params *params;
Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c 2006-09-10 22:23:59 UTC (rev 950)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2006-09-11 08:42:35 UTC (rev 951)
@@ -205,8 +205,27 @@
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 */
+
+/*--------------------------------------------------------------------*/
+
/*
* Make sure to end all lines with either a space or newline of the
* formatting will go haywire.
@@ -277,6 +296,11 @@
{ "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 }
};
Modified: trunk/varnish-cache/include/stat_field.h
===================================================================
--- trunk/varnish-cache/include/stat_field.h 2006-09-10 22:23:59 UTC (rev 950)
+++ trunk/varnish-cache/include/stat_field.h 2006-09-11 08:42:35 UTC (rev 951)
@@ -33,6 +33,9 @@
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")
More information about the varnish-commit
mailing list