[GSoC] 'Replace Runtime Hooks with Templates' progress and update thread

rikki cattermole rikki at cattermole.co.nz
Thu May 30 19:20:36 UTC 2019


On 31/05/2019 4:45 AM, H. S. Teoh wrote:
> On Thu, May 30, 2019 at 12:15:55PM +0000, Johannes Pfau via Digitalmars-d wrote:
> [...]
>> Now regarding this specific GSoC project: I don't think we have to
>> worry that this will affect compilation speed a lot. The compiler code
>> will be mostly identical, only instead of calling an extern(C)
>> function, it calls a template. Simple template instantiations are not
>> particularily slow though, so this should not cause much of a slow
>> down.
> 
> That depends on how the template is implemented, doesn't it?  If there
> are too many recursive templates, for example, the slowdown can be quite
> dramatic.
> 
> 
>> There is however one side-effect: Unlike the extern(C) functions used
>> before, template instances will be visible to the optimizer. This
>> means that parts of these hooks can be inlined and optimized to
>> improve performance. This however might affect compile time a bit.
> [...]
> 
> There's also the issue of code bloat, which should at least be
> considered, even if actually solving it might complicate things a bit
> too much for GSoC.  Previously copying an array from A to B involved
> only a single runtime function; now we're looking at O(n) template
> instantiations, which potentially translates to O(n) functions that,
> ostensibly, do the exact same copying of some number of bytes from A to
> B.

Agreed, I'm worried about template bloat.

But at the same time, I hope we can force inlining. If we can, that will 
solve that problem.


More information about the Digitalmars-d mailing list