swp_shrink: Try to reallocate big chunks
commit9e8cfe87439cdc04f9d7654deeda6bff128f9703
authorPetr Tesarik <petr@tesarici.cz>
Mon, 26 Sep 2011 18:09:42 +0000 (26 20:09 +0200)
committerPetr Tesarik <petr@tesarici.cz>
Mon, 26 Sep 2011 19:38:12 +0000 (26 21:38 +0200)
tree48b6c4fbb349a5d6a3fddb925dfdeef93e2d566e
parent5d569bd7ca968007c4ba6bcadfc37dc4633d2400
swp_shrink: Try to reallocate big chunks

If a chunk is larger than 1/4 of FILE_BLOCK_SIZE, the rest of the block
very often stays fragmented.

As an example, every insert starts by allocating full FILE_BLOCK_SIZE.
This can never be satisfied from a partial block, so a new block must
be allocated. When this block is later shrunk to the actual size of the
insert (possibly much smaller), the whole block will still be occupied,
and the rest is unlikely to be taken for another allocation, since there
is normally plenty of room in other partially full blocks...

Do not make a complete new allocation, only walk the free list, and if
there is no suitable chunk there, simply leave it as is.
src/file/swap.c