On 05/08/2013 05:57 AM, Namespace wrote:
> On Saturday, 9 March 2013 at 23:07:50 UTC, Ali Çehreli wrote:
>> On 03/09/2013 12:19 PM, Namespace wrote:
>>
>> > But structs with a bigger size aren't that performant if you
>> pass them
>> > as copy or move them (See also my small benchmark:
>>
>> I have started working on the DConf presentation about copy and move
>> semantics in D. I have done exactly the same type of tests and was
>> surprised how faster pass-by-reference can be.
>
> Hey, could you please publish your slides of your DConf presentation? :)
Yes, they are here:
http://acehreli.org/AliCehreli_copy_move_D.pdf
But I see that you have been after some test results between by-copy vs.
by-ref parameters. I have decided not to include them in the
presentation for various reasons: not enough presentation time, not
trusting my synthetic tests enough to be sure that I was covering all
aspects of the behaviors of modern cpu architectures, etc. I can say
that by-value was almost always slower in my little test.
However, as others have been saying, by-ref can be slower if a lot of
the members of the struct are accessed through that reference,
effectively defeating the CPU caches. For me to see that by-ref was
slower, I had to define huge structs, put them in huge arrays, and touch
all of the members of random elements of that array:
// s1 and s2 are random elements of huge arrays
void foo(ref const(S) s1, ref const(S) s2)
{
// use all members of s1 and s2
}
Only then by-ref was slower than by-value. Let me build more trust in my
test before opening it to discussion on the forums.
Ali