#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"
/*--------------------------------------------------------------------*/
/* 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);
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;
/*--------------------------------------------------------------------*/
+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.
"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 }
};