www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Compilation speed bechmark

reply Bottled Gin <gin bottle.com> writes:
There is this new programming language called vlang 
(http://vlang.io). Does not enthuse me because of its 'go' like 
syntax. Anyway, I came across a mention on hacker news 
https://news.ycombinator.com/item?id=19405036 where they boast of 
incredible compilation speed. D is mentioned in the comparison 
table and the DMD compiler is listed with a comment "segfault 
after 6 minutes".

The benchmark program is simple and silly. It goes like

import std.stdio;

void main() {
   int a;
   a = 1;
   writeln(a);
   a = 2;
   writeln(a);
   a = 3;
   writeln(a);
   // more such code lines till a = 400000
   // ....
}

I generated the code and tried compiling (with dmd-2.085.0) on my 
linux box. To my astonishment, it has been compiling for the last 
10 minutes without generating any object file.

Why does it take so long?
Mar 16
next sibling parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Sat, Mar 16, 2019 at 12:02:39PM +0000, Bottled Gin via Digitalmars-d wrote:
 There is this new programming language called vlang (http://vlang.io).
 Does not enthuse me because of its 'go' like syntax. Anyway, I came
 across a mention on hacker news
 https://news.ycombinator.com/item?id=19405036 where they boast of
 incredible compilation speed. D is mentioned in the comparison table
 and the DMD compiler is listed with a comment "segfault after 6
 minutes".
 
 The benchmark program is simple and silly. It goes like
 
 import std.stdio;
 
 void main() {
   int a;
   a = 1;
   writeln(a);
   a = 2;
   writeln(a);
   a = 3;
   writeln(a);
   // more such code lines till a = 400000
   // ....
 }
 
 I generated the code and tried compiling (with dmd-2.085.0) on my
 linux box.  To my astonishment, it has been compiling for the last 10
 minutes without generating any object file.
 
 Why does it take so long?
Because DMD has an O(n^2) algorithm that's run on the function body, so very large functions will incur huge amounts of compilation time. It would be nice to identify where this is and fix it, since having O(n^2) algorithms in a compiler that's supposed to be super-fast is rather silly. T -- It's bad luck to be superstitious. -- YHL
Mar 16
prev sibling parent kinke <noone nowhere.com> writes:
On Saturday, 16 March 2019 at 12:02:39 UTC, Bottled Gin wrote:
 [...]
https://issues.dlang.org/show_bug.cgi?id=19745
Mar 16