Templates are slow.

Ethan Watson via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 8 12:49:38 PDT 2016


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.


More information about the Digitalmars-d mailing list