arlo on 2 Jul 2003 18:19:02 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [ALACPP] smart pointers in C


> Hmm... mark-sweep collectors, provided you have a good allocator, should be
> able to outperform ref-counting smart pointers, particularly in a
> multi-threaded environment. I haven't looked at this particular GC, but I
> know of others which handedly kick smart pointers all over the place, at
> least for the common case.

Thanks. I hadn't been aware of that. Then I'll set the bar higher for the
performance trials, when I run them.

he was claiming that boost's shared pointers were faster. Given his
implementation and theirs, I'm not suprised. However, I may be able to get
sizable gains, in that case.

However, boost's numbers are rather impressive (in ns, including overhead for
a minimal tight loop):

                   initialization           copy operation
shared_ptr         1330 +/- 50              85 +/- 9
intrusive_ptr      1000 +/- 20              71 +/- 3
cyclic*            1290 +/- 70              112 +/- 12
raw                1038 +/- 30              10 +/- 5

The cyclic pointer is a proposed pointer for doing simple gc that is able to
collect cycles. It had a number of correctness issues, so was never added to
boost. These numbers were all for MSVC 6. The gcc 2.95.2 numbers were similar,
but between 1.5 and 2.5 times slower. All numbers were for release mode, with
default optimization settings.

The key thing here is that the non-intrusive boost shared pointer takes about
1.3 times as long to alloc, and 8.5 times as long to copy. There is room for a
mark-and-sweep gc to do better on copy, but it will not likely touch those
init times (even amortized). Overall, I expect the type of use to determine
which is faster. We'll see, if I ever get a compiler set up.

Honestly, I just want to get the gc pointer to about the same speed as the
shared_ptr. That one is fast enough for all the projects that I've ever worked
on.

Arlo


_______________________________________________
alacpp mailing list
alacpp@xxxxxxxxxxx
http://lists.ellipsis.cx/mailman/listinfo/alacpp