1) Reduce data chunk header size.
To keep track of chunk slots (total, first, last) variables of type int (4 bytes) are used. However chunks are limited to 64KB, so the number of lots can't be larger than ~4KB. Therefore we can safely use variables of type short 2 (bytes) to keep track of used slots. This will reduce the size of chunk header by 4 bytes (padding included). The patch is attached - valuecache-small-chunk-header.diff
2) Reduce initial value cache fragmentation
When starting up the value cache memory allocation pattern is like:
After some time the data chunks goes out of request range and are freed:
[item][free chunk][item][free chunk][item]...
However item freeing is not likely, so this memory will stay fragmented. To reduce this fragmentation it would be better to create a pool of pre-allocated items and take new items from this pool. Whenever the pool runs out of free items - create a new one. This way the items will not be interleaved with their data in value cache memory, resulting in less initial fragmentation: