Naive node.js faster than naive LDC2?
H. S. Teoh
hsteoh at quickfur.ath.cx
Sat Aug 22 16:15:14 UTC 2020
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.
T
--
Computers shouldn't beep through the keyhole.
More information about the Digitalmars-d
mailing list