Boost logo

Boost Users :

Subject: Re: [Boost-users] [Pool] correct usage for optimal performance
From: mike marchywka (marchywka_at_[hidden])
Date: 2009-12-07 09:14:16


On 12/7/09, Igor R <boost.lists_at_[hidden]> wrote:
> Hello,
>
> In my application I use singleton pools for the 2 most common
> allocation scenarios:
>
> 1) Frequent allocation of small objects (one by one, tens to hundreds
> per second). Every object is disposed soon after its allocation, so
> that only few objects are alive simultaniously.
> Since the objects are accessed through shared_ptr, I allocate them as
> follows:
>
> allocate_shared<Obj>(boost::fast_pool_allocator<Obj>());
>
> Is this the appropriate use of Pool for this scenario? Should I use
> pool_allocator (i.e. ordered_malloc()) instead?
>
> 2) Frequent (same as in (1) frequency and lifetime) allocation of
> memory blocks that look like this: [10Kb, 1Kb, 1.1Kb, 0.9Kb,...
> 10.5Kb...] - i.e. 1 big block, then several small ones. Each block is
> stored in shared_array, and I allocate it this way:
>
> shared_array<char> data_;
> //...
> typedef boost::singleton_pool<my_alloc_tag, 1024> allocator;
> int chunks = blockSize / allocator::requested_size + 1; // rough
> aproximation
> data_.reset(static_cast<char *>(allocator::malloc(chunks)),
> bind(&allocator::free, _1, chunks));
>
> Again, should I use here ordered_xxx? Or probably it's worth using
> allocator::maloc for the case of chunks==1, and ordered_malloc for
> chunks > 1?
>

I guess I would ask you and boost people about memory hierarchy issues.
Is boost cache aware and how does the user tell boost about access patterns?
Often locality and the avoidance of cache thrashing can be a big
performance issue with complicated algorithms or large data sets.

> Thanks!
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

-- 
marchywka_at_[hidden]
Mike Marchywka
586 Saint James Walk
Marietta GA 30067-7165
415-264-8477 (w)<- use this
404-788-1216 (C)<- leave message
989-348-4796 (P)<- emergency only
marchywka_at_[hidden]
Note: If I am asking for free stuff, I normally use for hobby/non-profit
information but may use in investment forums, public and private.
Please indicate any concerns if applicable.
Note: hotmail is censoring incoming mail using random criteria beyond
my control and often hangs my browser
but all my subscriptions are here..., try also marchywka_at_[hidden]

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net