Re: Can compiler profile itself?

2017-01-25 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 24 January 2017 at 23:25:12 UTC, Profile Anaysis 
wrote:
I am trying to compile some code and it takes around 6 seconds. 
Even if I change one line in one module, it takes the same 
time. There are about 20 different d modules.


[...]


yes the compiler can be used to profile itself.
build it with make ENABLE_PROFILE=1

If your code is overly slow you are probably using recursive 
variaidic templates.


Can compiler profile itself?

2017-01-24 Thread Profile Anaysis via Digitalmars-d-learn
I am trying to compile some code and it takes around 6 seconds. 
Even if I change one line in one module, it takes the same time. 
There are about 20 different d modules.


I used to get around 1-2 second compile times several months ago 
on different projects.


I did upgrade a few things and it seems that something has made 
things slow.


Can we ask the compiler what seems to be taking the most time(a 
module, a template, etc...)?


If the compiler can profile itself then it would be very easy to 
figure out what is slowing things down in compilation.


I feel that I should be able to compile all the modules 
separately and only have to recompile the module that I 
changed... and that it should be quite fast(e.g., if the module 
contains nothing but the main and a write statement, regardless 
of all the other stuff in the project, I'd expect that to be 
fast).


For example, If I do the

import std.stdio;

int main(string[] argv)
{
writeln("Hello D-World!");
return 0;
}

it takes <1s.

Yet if I import a bunch of modules it takes 6+s and the time 
never reduces on subsequent builds.


I am using Visual D.

Visual D has a separate compile and link feature but when I try 
it for dmdx64 I get


Internal error: backend\mscoffobj.c 2016

It does work for x32 but the speed does not change.

I'm convinved that dmd is recompiling everything each time... and 
this doesn't seem very fast IMO when less than 0.1% of the 
project has changed.