dmd makes D appear slow

weaselcat via Digitalmars-d digitalmars-d at puremagic.com
Fri May 29 12:04:03 PDT 2015


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)

dmd's backend is also under a proprietary license reducing the 
amount of people willing to contribute.
Not to mention that GDC and LDC benefit heavily from GCC and LLVM 
respectively, these aren't exactly one man projects(e.g, Google, 
Redhat, Intel, AMD etc contribute heavily to GCC and LLVM is 
basically Apple's baby.)

>
>
> [...]
>> 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

I think they probably should be if only for the licensing issues, 
dmd can't even be redistributed - AFAIK it's in very, very few D 
repositories on Linux.


re dicebot:

>I did make LDC default compiler used in Arch but now people are 
>unhappy with increased compile times so I may need to revert it 
>back :)

Maybe this should be brought up on LDC's issue tracker(that is, 
slower compilation times compared to dmd.)
Although it might have already been discussed.


More information about the Digitalmars-d mailing list