Slow performance compared to C++, ideas?

nazriel spam at dzfl.pl
Thu May 30 23:17:57 PDT 2013


On Friday, 31 May 2013 at 05:59:00 UTC, finalpatch wrote:
> You guys are awesome! I am happy to know that D can indeed 
> offer comparable speed to C++.
>
> But it also shows there is room for the compiler to improve as 
> the C++ version also makes heavy use of loops (or STL 
> algorithms) but they get inlined or unrolled automatically.
>
Agree.

I feel big hammer going towards my head from Walter/Andrei side 
but IMHO  abandoning DMD in the first place would be the best 
idea. Focusing on LDC or GDC would bring way much more benefits 
than trying to make anything from DMD. Version compiled with LDC 
runs in 202 ms and 192 μs. DMD... 1 sec, 891 ms, 571 μs, and 1 
hnsec

> On Friday, 31 May 2013 at 05:35:58 UTC, Juan Manuel Cabo wrote:
>> You might also try changing:
>>
>>            float[3] t = mixin("v[]"~op~"rhs.v[]");
>>            return Vec3(t[0], t[1], t[2]);
>>
>> for:
>>            Vec3 t;
>>            t.v[0] = mixin("v[0] "~op~" rhs.v[0]");
>>            t.v[1] = mixin("v[1] "~op~" rhs.v[1]");
>>            t.v[2] = mixin("v[2] "~op~" rhs.v[2]");
>>            return t;
>>
>> and so on, avoiding the float[3] and the v[] operations (which 
>> would
>> loop, unless the compiler/optimizer unrolls them (didn't 
>> check)).
>>
>> I tested this change (removing v[] ops) in Vec3 and in
>> normalize(), and it made your version slightly faster
>> with DMD (didn't check with ldmd2).
>>
>> --jm


More information about the Digitalmars-d mailing list