Limit chunk_bytes more strictly

The main cause for #11 seems to be that the chunk size in relation to
the memory cache was too big.

We now clamp it at memsz >> 10 (less than 1/1024 of the memsz).

This can still lead to issues when the memory size is reduced and
the cache reloaded, but then at least new objects will not compete
for the available memory.
parent 03efe55b
......@@ -31,6 +31,7 @@
#include "miniobj.h"
#include "fellow_const.h"
#include "fellow_tune.h"
#include "buddy_util.h"
......@@ -76,10 +77,23 @@ stvfe_tune_check(struct stvfe_tune *tune)
tune->chunk_exponent = l;
}
#endif
l = log2down(tune->memsz) - 4;
#define CHUNK_SHIFT 10
l = log2down(tune->memsz);
if (l < MIN_FELLOW_BITS + CHUNK_SHIFT)
l = MIN_FELLOW_BITS;
else
l -= CHUNK_SHIFT;
assert(l >= MIN_FELLOW_BITS);
if (tune->chunk_exponent > l) {
fprintf(stderr,"fellow: chunk_exponent limited to %u "
"(less than 1/16 of memory size)\n", l);
fprintf(stderr,"fellow: chunk_bytes (chunk_exponent) "
"limited to %zu (%u) "
"(less than 1/%zu of memory size, but at least %zu (%u))\n",
(size_t)1 << l, l,
(size_t)1 << CHUNK_SHIFT,
(size_t)1 << MIN_FELLOW_BITS, MIN_FELLOW_BITS);
tune->mem_reserve_chunks <<= (tune->chunk_exponent - l);
tune->dsk_reserve_chunks <<= (tune->chunk_exponent - l);
tune->chunk_exponent = l;
......
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