From: Greg Colvin (gcolvin_at_[hidden])
Date: 2000-01-31 13:59:47
From: Miki Jovanovic <miki_at_[hidden]>
> "greg colvin" <gcolvi-_at_[hidden]> wrote:
> > What is sad here is how easily Dave could hack up an allocator that is
> > way faster than the system defaults. There is no reason, given what we
> > know about memory allocation, for the system allocator to be any slower
> > than what Dave did, but vendors keep on shipping crap.
> The most important problem (for me) with using heap for storing ref
> counters, ptrs or anything is this: thread safety. To make it thread
> safe, everyone has to heavily protect their memory managers. Now, if
> you have lots of small units, smart pointers, lists, temporary objects
> all of them accessing heap, all of their memory allocations will have
> to be serialised, meaning only one thread at a time being allowed to
> allocate memory. This makes the memory manager a serious bottleneck in
> a real application.
You can write a thread-safe allocator with very low synchronization
overhead. All that needs to be serialized is pushing and poppping
a pointer on a free list, for which there are tricks on most chips,
such as the cmpxchg instruction on Intel.
So far boost has followed the C/C++ library tradition of ignoring
threading issues. I don't think we can get away with that for much
longer, but no one seems to have time and patience enough for the
assembly-level hacking it takes to do it right.
> So, while I am looking for a good/better smart pointer, I still use
> intrusive smart pointer in speed critical objects (also taking into
> account memory fragmentation from keeping the object and the reference
> counter separate).
The intrusive approach is almost sure to have the best performance,
but the results so far show the non-intrusive approaches to be close
enough for most purposes.
> Linked pointer seemed like a silver bullet, because it bypassed the
> memory manager, and still did not have big overheads, but now I see its
> drawbacks too. It is important to keep this conversation going just so
> as many facts and theories about the different implementations are
> Miki Jovanovic.
> Want to send money instantly to anyone, anywhere, anytime?
> You can today at X.com - and we'll give you $20 to try it! Sign
> up today at X.com. It's quick, free, & there's no obligation!
> -- Check out your group's private Chat room
> -- http://www.egroups.com/ChatPage?listName=boost&m=1
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk