Thread overview
Speeding up compilation of template-heavy code
Feb 22, 2020
Per Nordlöw
Feb 22, 2020
Dennis
Feb 22, 2020
drathier
Feb 22, 2020
Stefan Koch
Feb 23, 2020
drathier
Feb 22, 2020
Stefan Koch
Feb 22, 2020
Seb
February 22, 2020
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.
February 22, 2020
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.
February 22, 2020
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.
February 22, 2020
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
February 22, 2020
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?
February 22, 2020
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.
February 23, 2020
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.