www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Speeding up compilation of template-heavy code

reply Per =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
We're looking for a way to speed up compilation of template-heavy 
code. So we are trying to find out which parts of the code that 
is most costly to compile.

Is there a dmd flag that shows the code after template 
instantiations has been performed? Or some other dmd flag that 
can help out finding hot-spots in the compiler in our case.
Feb 22 2020
next sibling parent reply Dennis <dkorpel gmail.com> writes:
On Saturday, 22 February 2020 at 11:26:19 UTC, Per Nordlöw wrote:
 Is there a dmd flag that shows the code after template 
 instantiations has been performed?
The -vcg-ast flag does that.
Feb 22 2020
parent reply drathier <forum.dlang.org fi.fo> writes:
On Saturday, 22 February 2020 at 11:53:38 UTC, Dennis wrote:
 On Saturday, 22 February 2020 at 11:26:19 UTC, Per Nordlöw 
 wrote:
 Is there a dmd flag that shows the code after template 
 instantiations has been performed?
The -vcg-ast flag does that.
The d.cg files still contain templates, so it appears like they're instantiated after -vcg-ast?
Feb 22 2020
parent reply Stefan Koch <uplink.coder googlemail.com> writes:
On Saturday, 22 February 2020 at 12:24:56 UTC, drathier wrote:
 On Saturday, 22 February 2020 at 11:53:38 UTC, Dennis wrote:
 On Saturday, 22 February 2020 at 11:26:19 UTC, Per Nordlöw 
 wrote:
 Is there a dmd flag that shows the code after template 
 instantiations has been performed?
The -vcg-ast flag does that.
The d.cg files still contain templates, so it appears like they're instantiated after -vcg-ast?
no. -vcg-ast runs directly before codegen. All ast-rewriteing has already happend at that point. The reason it contains the template declarations is because they are still in the ast. There is no point in removing them.
Feb 22 2020
parent drathier <forum.dlang.org fi.fo> writes:
On Saturday, 22 February 2020 at 17:44:52 UTC, Stefan Koch wrote:
 no. -vcg-ast runs directly before codegen.
 All ast-rewriteing has already happend at that point.
 The reason it contains the template declarations is because 
 they are still in the ast.
 There is no point in removing them.
Thanks, I didn't even consider the possibility of a compiler mutating the ast in-place. Spent too much time writing Haskell, I guess.
Feb 23 2020
prev sibling next sibling parent Stefan Koch <uplink.coder googlemail.com> writes:
On Saturday, 22 February 2020 at 11:26:19 UTC, Per Nordlöw wrote:
 We're looking for a way to speed up compilation of 
 template-heavy code. So we are trying to find out which parts 
 of the code that is most costly to compile.

 Is there a dmd flag that shows the code after template 
 instantiations has been performed? Or some other dmd flag that 
 can help out finding hot-spots in the compiler in our case.
I have patches which add some tracing functionality. Another approach is to throw the -v flag and just count which semantic steps seem to take a long time.
Feb 22 2020
prev sibling parent Seb <seb wilzba.ch> writes:
On Saturday, 22 February 2020 at 11:26:19 UTC, Per Nordlöw wrote:
 We're looking for a way to speed up compilation of 
 template-heavy code. So we are trying to find out which parts 
 of the code that is most costly to compile.

 Is there a dmd flag that shows the code after template 
 instantiations has been performed? Or some other dmd flag that 
 can help out finding hot-spots in the compiler in our case.
https://github.com/CyberShadow/dmdprof
Feb 22 2020