Fix and properly document reserve limits

Could have caused #5, related to #10
parent 40a4b16e
......@@ -63,21 +63,6 @@ stvfe_tune_check(struct stvfe_tune *tune)
assert (tune->dsksz >= tune->memsz);
#ifdef DOES_THIS_MAKE_SENSE
/* the average object could be quite small, but larger chunks
* could be required, in which case it makes sense for the LRU
* to keep the larger chunks in the reserve
*/
l = log2up(tune->objsize_hint);
if (tune->chunk_exponent > l) {
fprintf(stderr, "fellow: chunk_exponent limited to %u "
"(next pow2 of objsize_hint)\n", l);
tune->mem_reserve_chunks <<= (tune->chunk_exponent - l);
tune->dsk_reserve_chunks <<= (tune->chunk_exponent - l);
tune->chunk_exponent = l;
}
#endif
#define CHUNK_SHIFT 10
l = log2down(tune->memsz);
......@@ -97,7 +82,7 @@ stvfe_tune_check(struct stvfe_tune *tune)
tune->chunk_exponent = l;
}
sz = tune->memsz >> (tune->chunk_exponent - 1);
sz = tune->memsz >> (tune->chunk_exponent + 3);
assert(sz <= UINT_MAX);
l = (unsigned)sz;
if (tune->mem_reserve_chunks > l) {
......@@ -106,6 +91,15 @@ stvfe_tune_check(struct stvfe_tune *tune)
tune->mem_reserve_chunks = l;
}
sz = tune->dsksz >> (tune->chunk_exponent + 3);
assert(sz <= UINT_MAX);
l = (unsigned)sz;
if (tune->dsk_reserve_chunks > l) {
fprintf(stderr,"fellow: dsk_reserve_chunks limited to %u "
"(less than 1/8 of disk size)\n", l);
tune->dsk_reserve_chunks = l;
}
//lint --e{685,568} misc const comparisons
#define TUNE(t, n, d, min, max) \
if (tune->n < (min)) \
......
......@@ -529,6 +529,7 @@ fellow storage can be fine tuned:
- unit: scalar
- default: 4
- minimum: 2
- maximum: dsksize / 8 / chunk_bytes
specifies a number of chunks to reserve on disk. The reserve is used
to fulfill storage requests when storage is otherwise full. Because
......@@ -538,11 +539,15 @@ fellow storage can be fine tuned:
fixed log space is full, might momentarily require additional space
before making room.
The value is capped suck that the number of reserved chunks times
the chunk size does not exceed 1/8 of the disk size.
* *mem_reserve_chunks*
- unit: scalar
- default: 1
- minimum: 0
- maximum: memsize / 8 / chunk_bytes
specifies a number of chunks to reserve in memory. The reserve is
used to provide memory for new objects or objects staged from disk
......@@ -550,6 +555,9 @@ fellow storage can be fine tuned:
latencies in these situations at the expense of some memory
unavailable for caching.
The value is capped suck that the number of reserved chunks times
the chunk size does not exceed 1/8 of the memory size.
* *objsize_hint*
- unit: bytes
......
......@@ -12,7 +12,7 @@ varnish v1 -arg "-p debug=+vclrel -p vsl_mask=+expkill" -vcl {
dsksize = 100MB,
memsize = 1MB,
objsize_hint = 64KB);
fellow.tune(chunk_bytes = 256KB);
fellow.tune(chunk_bytes = 256KB, mem_reserve_chunks = 999999, dsk_reserve_chunks = 99999);
fellow.as_transient();
}
sub vcl_synth {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment