Boost logo

Boost Users :

Subject: Re: [Boost-users] [Pool] Why is pool allocator slower than ordinaryallocator?
From: Brian Budge (brian.budge_at_[hidden])
Date: 2012-05-06 19:39:12


On Sat, May 5, 2012 at 7:36 AM, Mr.C64 <c64gio_at_[hidden]> wrote:
> On Sat, May 5, 2012 at 1:26 PM, John Maddock <boost.regex_at_[hidden]> wrote:
>
>> "FYI Boost.Pool isn't designed for or optimised for that usage - it's
>> designed for lots of fixed-sized blocks, as happens in a list (or even a map
>> or a set), it's not really designed for fast performance with variable sized
>> blocks as happens in a string or a vector."
>>
>
> Do you know of any open-source allocator (available in Boost or elsewhere),
> that can be used to *quickly* allocate instances of std::wstring, using an
> allocation pattern like the one showed in the following blog post?
>
>  http://tinyurl.com/cu3lzwz
>
> Thanks,
> Mr.C64
>

This is a pretty simple pattern. You could design your own arena
allocator for this. Consider a deque std::vector<wchar_t> where each
successive vector is some factor larger than the prior. You can just
place '\0' delimited strings in that memory, and return it. At the
end, when you no longer need your dictionary strings, just clear()
your deque. You could go a little lower level for even better
performance, but this should already beat the standard allocator by
quite a bit.

  Brian


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