[dmd-internals] Windows DMD development is now impossible

Don Clugston dclugston at gmail.com
Tue Jun 11 00:35:31 PDT 2013


On 10 June 2013 21:41, Walter Bright <walter at digitalmars.com> wrote:

>
> On 6/9/2013 11:29 PM, Don Clugston wrote:
>
>>
>>
>> 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.
>>
>>
> The template instantiation code is short-circuited if the instantiation
> already exists. (It's a bad bug if this is broken.)
>
>
It's not a compiler bug. It's something more interesting.
I counted the number of instantiations in std.algorithm -unittest.
635 templates are instantiated, half of them only 1 to 10 times.
These ones here cover 70% of the total.

70763    isNarrowString
31279    binaryFun
24425    isInputRange
22308    Unqual
15563    startsWith
15381    isBidirectionalRange
11405    endsWith
7861    FormatSpec
7277    OriginalType
7275    to
6723    TypeTuple
5827    defaultInit
5713    from
5413    isRawStaticArray

Then, the question is, how do we get 71K different types to instantiate
isNarrowString with? There aren't nearly that many types declared in the
program!
Turns our it's things like:

Zip!(Sequence!("n", Tuple!(ulong)), Sequence!("n", Tuple!(int)), Result,
Repeat!(Sequence!("n", Tuple!(int))), Repeat!(Result))

So we've got a combinatorial explosion of types happening here. I'm sure
that's true for the other massively-instantiated templates as well. If we
could avoid this, we would get an order of magnitude improvement in memory
usage and compilation time.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-internals/attachments/20130611/c3df0565/attachment.html>


More information about the dmd-internals mailing list