On Friday, 29 May 2015 at 18:38:20 UTC, H. S. Teoh wrote:
On Fri, May 29, 2015 at 06:13:02PM +0000, weaselcat via
Digitalmars-d wrote:
In nearly every benchmark I see D in, the default compiler
used is dmd
which runs computationally intense tasks 4-5x+ slower than
GDC/LDC
As I keep saying, in my own compute-intensive projects I have
consistently found that dmd-generated code (dmd -O -inline
-release) is
about 20-30% slower on average, sometimes even up to 50% slower,
compared to gdc-generated code (gdc -O3 -finline -frelease).
This is
measured by actual running time in an actual application, not
benchmark-specific code.
I have looked at the generated assembly before, and it's clear
that the
gdc optimizer is way ahead of dmd's. The dmd optimizer starts
failing to
inline inner loop code after about 1-2 levels of function call
nesting,
not to mention it's unable to factor out a lot of loop
boilerplate code.
The gdc optimizer, by contrast, not only factors out almost all
loop
boilerplate code and inlines inner loop function calls several
levels
deep, it also unrolls loops in a CPU-specific way, does major
loop
restructuring, compounded with much more linear code
optimization than
dmd does, instruction reordering and then refactoring after
that, etc.,
in some cases reducing the size of inner loop code (as in, the
amount of
code that runs per iteration) by up to 90%.
I don't know the internal workings of the dmd optimizer, but
it's clear
that at present, with almost nobody working on it except
Walter, it's
never going to catch up. (Maybe this statement will provoke
Walter into
working his magic? :-P)
[...]
This isn't the first time I've seen this, in basically every
benchmark
featuring D I have to submit a patch/make a comment that dmd
shouldn't
be used. Make no mistake, this is damaging to D's reputation -
how
well does D's "native efficiency" go over when people are
saying it's
slower than Scala and F#(mono)?
LDC and GDC need promoted more.
[...]
This will probably offend some people, but I think LDC/GDC
should be the
default download on dlang.org, and dmd should be provided as an
alternative for those who want the latest language version and
don't
mind the speed compromise.
T
LDC can work wonders, indeed. I've seen it. Drawback: GDC and LDC
lag behind.
D doesn't like legacy code, so I always update my code.
Maybe we could synchronize dmd, ldc and gdc faster? Dmd is the
only way to update your code.