[dmd-internals] Windows DMD development is now impossible

deadal nix deadalnix at gmail.com
Mon Jun 10 21:58:16 PDT 2013


One area where template bloat can be reduced is using cannonical symbol for
alias parater forwarding. Let me explain with a sample of code :

template A(alias foo) {}
template B(alias foo) {
    alias afoo = A!foo;
}

B!symbol;

In this case, A is instanciated with B!symbol.foo as alias parameter, not
symbol. This cause a huge amunt of useless template instanciation when
compiling SDC (and can somtime cause infinite template instanciation that
crash the compiler).


2013/6/10 Don Clugston <dclugston at gmail.com>

>
> On 10 June 2013 02:28, Walter Bright <walter at digitalmars.com> wrote:
>
>>
>> On 6/9/2013 1:32 PM, Don Clugston wrote:
>>
>>>
>>> Yeah. 4 orders of magnitude. Our codebase at sociomantic is a bit larger
>>> than Phobos + druntime, but it compiles in just a few seconds.
>>> The problem is, that because of templates, the memory consumption isn't
>>> linear with source size.
>>>
>>> dmd -unittest -o- std/algorithm
>>>
>>> instantiates 344150 templates. Yes 344K. More than a third of a million.
>>>
>>
>> Wow! (How many of those are unique, rather than reusing an existing
>> instantiation?)
>
>
> I'm not sure. That's the number of calls to the constructor of
> TemplateInstance. I don't understand the code well enough to know
> if it can eventually gets merged with an existing TemplateInstance.
> If so, then perhaps there's something we could do to prevent them from
> getting created in the first place if they are duplicates.
> Certainly there are a huge number of instantiations of things like:
> hasLength, isNarrowString, isForwardRange
> It seems hard to believe there would be enough types to instantiate
> isNarrowString thousands of different times.
>
>
>  More than the number of lines of source in the module.
>> And yet there are only 1305 asserts in that module -- the tests are not
>> particularly comprehensive.
>>
>>
> -cov shows 96% coverage for std.algorithm
>
>
> Yeah, my point was that for N tests, we get O(N^^2) templates instantiated.
>
>
> _______________________________________________
> dmd-internals mailing list
> dmd-internals at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-internals
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-internals/attachments/20130611/1b818dc5/attachment.html>


More information about the dmd-internals mailing list