Disappointing performance from DMD/Phobos

Manu turkeyman at gmail.com
Tue Jun 26 17:38:42 UTC 2018


On Mon, 25 Jun 2018 at 20:17, Jonathan M Davis via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> dmd's inliner is notoriously poor,

I know, but it's still the reference compiler, and it should at least
to a reasonable job at the kind of D code that it's *recommended* that
users write.
That line of code is the sort of line that should showcase what you
can do with D that you can't do with other languages... but DMD will
lead you to believe that you can't do it with D either.
My point is, it's a really bad thing to present to users. DMD should
really care about that impression.

> but I don't know how much effort has
> really been put into fixing the problem. I do recall it being argued several
> times that it only should only be in the backend and that there shouldn't be
> one in the frontend, but either way, the typical solution seems to be to use
> ldc instead of dmd if you really care about the performance of the generated
> binary.

I'm using unreleased 2.081, which isn't in LDC yet. Also, LDC seems to
have more problems with debuginfo than DMD.
Once LDC is on 2.081, I might have to flood their bugtracker with
debuginfo related issues.

> So, all in all, the result is not great for dmd's performance. I don't know
> what the solution is, though I agree that we're better off if dmd generates
> fast code in general even if it's not as good as what ldc does.

It's not so much that I expect perfect optimisation, but this is a
failure to detect a prolific and recommended pattern used in a lot of
D code.
I think extra care should be taken to make such common code at least
approach a users expectation for codegen.

> Regardless, if you can give simple test cases that clearly should be
> generating far better code than they are, then at least there's a clear
> target for improvement rather than just "dmd should generate faster code,"
> so there's something clearly actionable.

I'm pretty sure that's exactly what I did above...
Build that code, suggest; don't generate a callstack 7-levels deep.
Ideally, observe inline code that adds 4 ints together.


More information about the Digitalmars-d mailing list