Boost logo

Boost :

From: David Maisonave (boost_at_[hidden])
Date: 2006-01-30 06:23:44


"Daniel Wallin" <dalwan01_at_[hidden]> wrote in message
news:<drkmls$kb5$1_at_[hidden]>...
> David Maisonave wrote:
> > The only advantage I found with reference-count is that it requires
> > less memory. Other than that, in my test it performs the worse when
> > compared to reference-link and reference-intrusive.
> > I don't understand why reference-count was picked instead of
reference-link
> > for the boost::shared_ptr
>
> It's in the FAQ:
>
> http://www.boost.org/libs/smart_ptr/shared_ptr.htm#FAQ
>
> Q. Why doesn't shared_ptr use a linked list implementation?
>
> A. A linked list implementation does not offer enough advantages to
> offset the added cost of an extra pointer. See timings page. In
> addition, it is expensive to make a linked list implementation
> thread safe.

You can avoid having to make the implementation thread safe by making the
pointee thread safe.
This can be done by using an intrusive lock.

On my test, reference-link is over 25% faster than reference-count logic for
initialization.
With BOOST_SP_USE_QUICK_ALLOCATOR defined, than reference-link is over 30%
faster than reference-count logic for initialization.
I get the above results using VC++ 7.1, and if I use the GNU 3.x compiler,
than the difference is even greater in favor of reference-link logic.
With the Borland compiler, the difference is about 22%

I guess this could be considered not enough of an advantage if 22% to 30%
extra efficiency is not that important.
But some developers would differ.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk