Boost logo

Boost :

Subject: Re: [boost] ASIO into the standard
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2014-07-14 06:02:03

El 14/07/2014 2:33, Gavin Lambert escribió:
> On 12/07/2014 07:41, Ion Gaztañaga wrote:
>> Linux allocator is based on ptmalloc2 which is based on DLMalloc, so for
>> usual allocations they should perform similarly. On multithreaded
>> scenarios the default allocator should be better. In Windows the
>> performance improvement is noticeable.
> I haven't tested these allocators, but it seems worth mentioning that
> for general allocations, while ptmalloc2 is a significant performance
> improvement vs. the Windows XP allocator, it makes little difference vs.
> the Windows 7 allocator, at least in my tests.

For single threaded executions, in Windows 7 and Visual 2010 I've seen
in bench_alloc_stable_vector (which tests burst allocation for node
containers like stable_vector):

   Iterations/Elements: 400/10000
Allocator: StdAllocator stable_vector<MyInt>
   allocation ns: 70.4541 deallocation ns: 2.12974

Allocator: AllocatorPlusV1 stable_vector<MyInt>
   allocation ns: 56.1535 deallocation ns: 2.07784

Allocator: AllocatorPlusV2 stable_vector<MyInt>
   allocation ns: 29.7252 deallocation ns: 2.06671

Allocator: AdPool2PercentV2 stable_vector<MyInt>
   allocation ns: 28.3165 deallocation ns: 1.93169

It shows that when executing a range insertion in stable_vector:

l.insert(l.end(), num_elements, MyInt(r));

with Windows allocator we need 70 ns per element, with DLMalloc we need
56 (-20%) and with burst allocation we only need 29ns (-58%). Note that
this is not only the time to allocate memory, it counts also the common
tasks of linking and updating internal structures.

Maybe more recent Visual Studios have improved the default allocator (I
think the allocator depends more on the C runtime than in the OS).

In MSVC 10.0 the buffer expansion (realloc-like) test

   Iterations/Elements: 10000/10000

Allocator: StdAllocator //std::vector
   push_back ns: 4.88223
   capacity - alloc calls (new/expand): 12138 - 0(0/0)

Allocator: StdAllocator //boost::container::vector
   push_back ns: 3.98395
   capacity - alloc calls (new/expand): 16384 - 15(15/0)

Allocator: AllocatorPlusV2 //boost::container::vector
   push_back ns: 2.12294
   capacity - alloc calls (new/expand): 16383 - 13(1/12)

In MSVC 7.1 the default allocator is slower:

Allocator: StdAllocator //std::vector
   push_back ns: 7.00777
   capacity - alloc calls (new/expand): 12138 - 0(0/0)

Boost.Container allocators should help when inserting a range of values,
making copies of containers, etc.



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