[Pool] correct usage for optimal performance
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
On 12/7/09, Igor R
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
allocator; int chunks = blockSize / allocator::requested_size + 1; // rough aproximation data_.reset(static_cast (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@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- marchywka@gmail.com 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@hotmail.com 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@yahoo.com
participants (2)
-
Igor R
-
mike marchywka