Templates are slow.

Stefan Koch via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 8 13:10:01 PDT 2016


On Thursday, 8 September 2016 at 19:49:38 UTC, Ethan Watson wrote:
> On Thursday, 8 September 2016 at 19:17:42 UTC, Lewis wrote:
>> I can't help but wonder if there were some way to 
>> automatically cache templates instantiations between runs of 
>> dmd?
>
> I'm running with Visual D, which has a "COMPILE ALL THE THINGS" 
> mentality as the default. As part of the rapid iteration part 
> of Binderoo, I plan on doing incremental linking.
>
> Of course, if all template instantiations go in to one object 
> file, that really ruins it. Each template instantiation going 
> in to a separate object file will actually make life 
> significantly easier, as each compile will have less output. 
> The only time those template instantiations need to recompile 
> is if the invoking module changes; the template's dependencies 
> change; or the module the template lives in changes.
>
> My opinion is that splitting up object files will do more to 
> reduce compile time for me than anything else, the pipeline we 
> had for Quantum Break was to compile and link in separate steps 
> so it's not much effort at all for me to keep that idea running 
> in Binderoo and make it incrementally link. But I don't know 
> the DMD code and I'm not a compiler writer, so I cannot say 
> that authoritatively. It sounds very reasonable to me at least.

generating separate object files for each template instanciation 
is and then only re-generating on change will only be effective 
if they do not change much.
 From one build to the next.

For binderoos purpose this could be rather effective.
As long as no one adds fields at the beginning of the structs :)
Without incremental linking however your compile-times will shoot 
through the roof. And will probably damage the moon as well.



More information about the Digitalmars-d mailing list