digitalmars.D.bugs - [Issue 14937] New: Slow code compared to ldc/gdc on calculation with
- via Digitalmars-d-bugs (41/41) Aug 19 2015 https://issues.dlang.org/show_bug.cgi?id=14937
https://issues.dlang.org/show_bug.cgi?id=14937 Issue ID: 14937 Summary: Slow code compared to ldc/gdc on calculation with real variables Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: secondaryAccount web.de Created attachment 1542 --> https://issues.dlang.org/attachment.cgi?id=1542&action=edit benchmarked code http://forum.dlang.org/thread/mqv2ct$1cpp$1 digitalmars.com?page=9#post-mr2ef5:241e2a:241:40digitalmars.com The code is in the attachment. Timings with some test input described below: dmd -O -inline -release -noboundscheck 3700-3800 ms gdc -O3 -march=native -frelease -fno-bounds-check ~1000 ms ldc2 -O3 -release -disable-boundscheck ~800 ms versions: dmd 2.068 gdc based on 4.9.2 ldc 0.15.2beta1 OS: linux X86_64 Some notes: - the benchmark is calling cosineSimilarity 1 million times with different input and sum the return values (large text input file + IO functions omitted here. I can add them if helpful.) - timing with std.datetime around the loop - no IO included. - pragma(inline, true) shows that dmd is unable to inline scalarProduct and normSquared. disabling inlining for ldc causes no noticeable slowdown. - elements of SparseVector are sorted by index. - SparseVector.length is usually between 50 and 100 and maximal index is 47,000 - v1 and v2 are not pointing to the same data. - gap between dmd and ldc/gdc is much smaller when replacing "real" with double. --
Aug 19 2015