[pool] doubling algorithm

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. Boris

From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] 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 --------------------------- ----------- --------------------------------- UserAllocator::nextSize( n, partition_sz) 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 size. --------------------------------------------------------------------------- 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 --------------------------- ----------- --------------------------------- GrowthStrategy::nextSize( n, partition_sz) size_type (same as above) -------------------------------------------------------------------------- I'd be interested in hearing your thoughts and ideas... -Chris

On Wed, 22 Oct 2008 20:50:42 +0200, Chris Newbold <Chris.Newbold@mathworks.com> wrote: Hi Chris,
[...]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:
[...] Solution (2) introduces a new concept, GrowthStrategy, as an additional template argument for boost::pool (and the other related pool types):
[...] I'd be interested in hearing your thoughts and ideas...
I'm fine with both solutions. :) As the UserAllocator concept exists already it might be easier though to simply add a next_size() member function there? As the concept is rather small and as it's very easy to define your own user-defined allocator I think it's also fine to add another member function. So far I would be glad if I could change the doubling algorithm at all - the extra flexibility with a GrowthStrategy concept is something I don't need at least. In case you change UserAllocator (or add the GrowthStrategy concept) soon and need a tester just tell me! I'll have to modify pool.hpp now anyway as I urgently need to get rid of the doubling algorithm. Boris

Boris wrote:
[...]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:
[...] Solution (2) introduces a new concept, GrowthStrategy, as an additional template argument for boost::pool (and the other related pool types):
[...] I'd be interested in hearing your thoughts and ideas...
In case you change UserAllocator (or add the GrowthStrategy concept) soon and need a tester just tell me! I'll have to modify pool.hpp now anyway as I urgently need to get rid of the doubling algorithm.
Just so you both know, I don't think Boost.Pool has a maintainer at present, so if either or both if you would like to step up to the plate and submit the necessary changes that would be great! John.

From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of John Maddock Sent: Thursday, October 23, 2008 4:00 AM
Just so you both know, I don't think Boost.Pool has a maintainer at present, so if either or both if you would like to step up to the plate and submit the necessary changes that would be great!
I took over maintainership a couple months back... :) -Chris

Chris Newbold wrote:
From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of John Maddock Sent: Thursday, October 23, 2008 4:00 AM
Just so you both know, I don't think Boost.Pool has a maintainer at present, so if either or both if you would like to step up to the plate and submit the necessary changes that would be great!
I took over maintainership a couple months back...
:)
Excellent ! :-) Apologies for missing that, John.
participants (3)
-
Boris
-
Chris Newbold
-
John Maddock