isl_blk: don't reuse overly large blocks for small allocations
authorSven Verdoolaege <skimo@kotnet.org>
Sun, 10 Apr 2011 08:57:11 +0000 (10:57 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Thu, 21 Apr 2011 11:13:11 +0000 (13:13 +0200)
commit4873addae63570d1bf3032a68cbdf828ba63d240
treeaa37f9d63d3d3db4c5386f7279c2396c81bcab2e
parente4b14abb6299fe47d3a2c30621816bcb5d279759
isl_blk: don't reuse overly large blocks for small allocations

We usually allocate a large number of small objects, but occasionally
we may allocate one or more big objects.  The original caching code
could reuse a cached huge object for a small allocation.
This is fine if the object would grow later, but if it remains
small, then we may end up consuming and wasting a lot of memory,
especially if these objects are long-lived.

Now we only a memory block if it is at most twice as big as the desired
size.  This may result in some large objects sticking around in the cache,
so we evict objects from the cache after a while.
Finally, we don't reuse any cache elements for initially zero sized
allocations, but instead check the cache when the objects first growns
to a non-zero size.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_blk.c
isl_ctx.c
isl_ctx_private.h