From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-08-25 09:29:37
Maxim Yegorushkin wrote:
> On Thu, 25 Aug 2005 17:34:59 +0400, Peter Dimov <pdimov_at_[hidden]>
>> Maxim Yegorushkin wrote:
>>> I just skimmed through boost/detail/quick_allocator.hpp and noticed
>>> that quick_allocator causes false sharing on SMP. It happens when
>>> several counters are allocated within the same cache line and those
>>> counters are used by different processors, thus thrashing
>>> processors' cache lines when the counter is written, even when the
>>> counter is used by a single processor only.
>> What do you suggest?
> IMO, patching it to avoid false sharing may require too much effort.
That, and it would increase the memory footprint.
> Not quite constructive, but I would stick to using standard
> new/delete and replaced libc provided malloc() with hoard's one for
> my project.
That's always been the recommended course of action. quick_allocator is for
(a) benchmarks that use a horribly slow underlying malloc, (b) people that
try the #define and their particular project tends to benefit a lot, and (c)
people that want to customize the allocations of their local copy of
shared_ptr, but need a starting point.
It's very much a "toy" compared to industrial grade malloc replacements,
especially in MT mode, where you definitely want thread-specific (or at the
very least, lock free) free lists. False sharing is rarely at the top of
your worries on high contention SMP. :-)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk