Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poor codegen optimization for ranges #17705

Open
dlangBugzillaToGithub opened this issue Apr 25, 2015 · 2 comments
Open

Poor codegen optimization for ranges #17705

dlangBugzillaToGithub opened this issue Apr 25, 2015 · 2 comments
Labels

Comments

@dlangBugzillaToGithub
Copy link

weaselcat reported this on 2015-04-25T01:25:32Z

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

CC List

  • weaselcat
  • safety0ff.bugz

Description

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.
@dlangBugzillaToGithub
Copy link
Author

r9shackleford commented on 2015-04-25T23:41:04Z

Upon closer inspection, I believe this is an inlining issue, possibly related to cross-module inlining. If I move the function to another file, LDC achieves similar performance as GDC - but it goes away with singleobj flag.

this kills range performance.

coincidentally, on arch linux LDC is the only compiler that doesn't use a statically linked phobos. Maybe related?

@dlangBugzillaToGithub
Copy link
Author

safety0ff.bugz commented on 2015-04-26T00:41:32Z

(In reply to weaselcat from comment #0)
> 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.
>

AFAIK slow version allocates a closure on the heap, perhaps LDC optimizes out unnecessary closures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant