Boost logo

Boost :

Subject: Re: [boost] [Block Pointer] benchmark
From: Darren Garvey (darren.garvey_at_[hidden])
Date: 2011-05-25 20:42:41


On 26 May 2011 00:15, Phil Endecott <spam_from_boost_dev_at_[hidden]>wrote:

> Phil Bouchard <philippe_at_[hidden]> wrote:
>
>> On 5/25/2011 3:27 PM, Nevin Liber wrote:
>>
>>>
>>> You have yet to explain why your make_auto is so much slower than new
>>> directly. It just isn't that expensive to copy one pointer and zero out
>>> another. I can't imagine what else your code can possibly be doing. I
>>> can't imagine how that can be more, let alone significantly more
>>> expensive
>>> than a heap allocation. Enlighten me.
>>>
>>
>> Well if you have a direct assignment coming from operator new then the
>> pointer can be transferred directly into a register. If you have temporary
>> r-values to copy it into then the transfer will be done from one memory
>> location to another, but it won't be a fast as a register-to-register
>> transfer.
>>
>
> That effect should be immeasurably small, or eliminated entirely by the
> compiler.
>
> I think you had better post your benchmark code. There must surely be
> something else going on here.

I believe he has already (modulo if he incorporated the minor change I
mentioned):
https://svn.boost.org/svn/boost/sandbox/block_ptr/libs/smart_ptr/example/benchmark.cpp

I agree though, it isn't clear that your code is representative of "real"
code. You should try not using templates - which take function pointers - to
do the work and inline the code into the tests *.

It would be interesting to see the assembly produced by your compiler (I'm
not sure you've said which one you're using) in a fully optimised release
build of the tests too, just to see what's going on under the hood.

-- 
Darren
* If using the templates to do the tests impact performance, that's still
useful information, I think.

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