#include <sys/time.h>
#include "shmlog.h"
+#include "heritage.h"
#include "cache.h"
/*--------------------------------------------------------------------*/
* 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);
/* Fetcher hints */
unsigned fetch_chunksize;
+
+ /* Sendfile object minimum size */
+ unsigned sendfile_threshold;
};
extern struct params *params;
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 */
+
/*--------------------------------------------------------------------*/
/*
{ "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 }
};
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")