www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14498] New: Poor codegen optimization for ranges

https://issues.dlang.org/show_bug.cgi?id=14498

          Issue ID: 14498
           Summary: Poor codegen optimization for ranges
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: r9shackleford gmail.com

dmd and gdc do _very_ poorly on a benchmark featuring D due to what I assume is
poor codegen.

https://github.com/logicchains/LPATHBench/blob/master/d.d

using the "slow"(aka ranges) version, DMD produces code that is 4 times slower.
Almost same exact ratios for GDC, so I assume it's due to frontend(?)

LDC seems to optimize it away to almost identical performance between "fast"
and "slow" version, unsure if it's due to the LLVM optimizations or one of
their patches to dmd.


dmd 2.067 GC summary for fast version:
    Number of collections:  1
    Total GC prep time:  0 milliseconds
    Total mark time:  0 milliseconds
    Total sweep time:  0 milliseconds
    Total page recovery time:  0 milliseconds
    Max Pause Time:  0 milliseconds
    Grand total GC time:  0 milliseconds
GC summary:    1 MB,    1 GC    0 ms, Pauses    0 ms <    0 ms

dmd 2.067 GC summary for range version:
    Number of collections:  2711
    Total GC prep time:  13 milliseconds
    Total mark time:  67 milliseconds
    Total sweep time:  370 milliseconds
    Total page recovery time:  75 milliseconds
    Max Pause Time:  0 milliseconds
    Grand total GC time:  526 milliseconds
GC summary:    1 MB, 2711 GC  526 ms, Pauses   80 ms <    0 ms

second number is runtime in ms, optimization flags relevant to compilers are
enabled.

./dmd_slow
8981 LANGUAGE D 7311
./dmd_fast
8981 LANGUAGE D 1835
./gdc_slow
8981 LANGUAGE D 4249
./gdc_fast
8981 LANGUAGE D 903
./ldc_slow
8981 LANGUAGE D 999
./ldc_fast
8981 LANGUAGE D 1078

I marked this as a DMD issue due to LDC producing an expected output despite it
being related to phobos.

--
Apr 24 2015