[dmd-internals] Windows DMD development is now impossible

Walter Bright walter at digitalmars.com
Tue Jun 11 01:06:50 PDT 2013


On 6/11/2013 12:35 AM, Don Clugston wrote:
>
>
> 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.
>
>

This is great information. 71000 instantiations of isNarrowString!! Definitely 
need a hash rather than a linear list. I had no idea. You're right, though, 
about figuring out a way to avoid this. isNarrowString is nothing more than:

template isNarrowString(T)
{
     enum isNarrowString = (is(T : const char[]) || is(T : const wchar[])) && 
!isAggregateType!T;
}

Makes me wonder why isAggregateType is not 71000 instantiations, too?

Maybe we can avoid generating a mangled name for a template if it is an 
eponymous one that evaluates to a manifest constant? This will save a ton of memory.



More information about the dmd-internals mailing list