Boost logo

Boost :

Subject: Re: [boost] [pool] doubling algorithm
From: Chris Newbold (Chris.Newbold_at_[hidden])
Date: 2008-10-22 14:50:42

> From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]]
> On Behalf Of Boris
> Sent: Wednesday, October 22, 2008 1:27 PM

> Are there any plans to make the pool's doubling algorithm configurable? It
> would be great if it was possible for example to set an upper limit or to
> use constant chunk sizes (thus no algorithm at all). If there are no plans
> may I propose then some patches? I ask as I need to configure the pool as
> it eats too much memory sometimes.

Parameterizing the growth algorithm for the pool is pretty high on my to-do list, as we have also found the default doubling algorithm to been overly-aggressive.

My thinking is only half-baked, but it seemed natural to me to implement this via template-based policies. The two alternatives that came to mind were to either (1) integrate support for controlling growth into the existing UserAllocator concept; or (2) add an additional template parameter to boost::pool to allow the growth strategy to be configured independently of the UserAllocator.

Solution (1) would result in the following additional required semantics for a UserAllocator implementation:

Expression Return Type Pre-Condition/Notes
--------------------------- ----------- ---------------------------------
                            size_type Growth strategy support; given
                                         an existing allocation size of n
                                         elements each of partition_sz,
                                         return the suggested number of
                                         elements for the next allocation
                                         request. If n is zero, returns
                                         the suggested initial allocation

Solution (2) introduces a new concept, GrowthStrategy, as an additional template argument for boost::pool (and the other related pool types):

template <typename UserAllocator = default_user_allocator_new_delete,
          typename GrowthStrategy = default_growth_strategy>
class pool;

GrowthStrategy would have the following semantics:

Expression Return Type Pre-Condition/Notes
--------------------------- ----------- ---------------------------------
                            size_type (same as above)

I'd be interested in hearing your thoughts and ideas...


Boost list run by bdawes at, gregod at, cpdaniel at, john at