Naive node.js faster than naive LDC2?
bachmeier
no at spam.net
Mon Aug 24 17:03:38 UTC 2020
On Saturday, 22 August 2020 at 16:15:14 UTC, H. S. Teoh wrote:
> On Sat, Aug 22, 2020 at 02:08:40AM +0000, bachmeier via
> Digitalmars-d wrote: [...]
>> I have no desire to dig into it myself, but I'll just note
>> that if you check the CLBG, you'll see that it's not hard to
>> write C and C++ programs for this benchmark that are many
>> times slower than Node JS. The worst of them takes seven times
>> longer to run.
>
> As described in my other post, my analysis of James' code
> reveals the following issues:
>
> 1) Using class instead of struct;
>
> 2) Using real instead of double;
>
> 3) std.math.fmax calling the C library (involving a PIC
> indirection to a
> shared library as opposed to inlineable native D code).
>
> Addressing all 3 issues yielded a 67% improvement (from class +
> real + C
> fmax -> struct + double + native fmax), or 37% improvement
> (from class +
> double + C fmax -> struct + double + native fmax).
>
> I don't have a Node.js environment, though, so I can't make a
> direct comparison with the optimized D version.
>
> I will note, though, that (1) and (2) are well-known
> performance issues; I'm surprised that this was not taken into
> account in the original comparison. (3) is something worth
> considering for std.math -- yes it's troublesome to have to
> maintain D versions of these functions, but they *could* make a
> potentially big performance impact by being inlineable in hot
> inner loops.
Well, I'm not going to debate the possibility that D will
outperform Node with appropriate optimization. It's clear from
the C and C++ timings, though, that you can't just type out a C,
C++, or D program and expect to beat Node - it's going to take
some care and knowledge that you really don't need with Node.
More information about the Digitalmars-d
mailing list