<div dir="ltr"><div><div><div>One area where template bloat can be reduced is using cannonical symbol for alias parater forwarding. Let me explain with a sample of code :<br><br></div>template A(alias foo) {}<br></div>template B(alias foo) {<br>

</div>    alias afoo = A!foo;<br><div>}<br><br></div><div>B!symbol;<br><br></div><div>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).<br>

</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/6/10 Don Clugston <span dir="ltr"><<a href="mailto:dclugston@gmail.com" target="_blank">dclugston@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote"><div class="im">On 10 June 2013 02:28, Walter Bright <span dir="ltr"><<a href="mailto:walter@digitalmars.com" target="_blank">walter@digitalmars.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><br>
On 6/9/2013 1:32 PM, Don Clugston wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Yeah. 4 orders of magnitude. Our codebase at sociomantic is a bit larger than Phobos + druntime, but it compiles in just a few seconds.<br>
The problem is, that because of templates, the memory consumption isn't linear with source size.<br>
<br>
dmd -unittest -o- std/algorithm<br>
<br>
instantiates 344150 templates. Yes 344K. More than a third of a million.<br>
</blockquote>
<br></div>
Wow! (How many of those are unique, rather than reusing an existing instantiation?)</blockquote><div><br></div></div><div>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<br>


</div><div>if it can eventually gets merged with an existing TemplateInstance.<br></div><div>If so, then perhaps there's something we could do to prevent them from getting created in the first place if they are duplicates.<br>


</div><div>Certainly there are a huge number of instantiations of things like:<br></div><div>hasLength, isNarrowString, isForwardRange<br></div><div>It seems hard to believe there would be enough types to instantiate isNarrowString thousands of different times.<br>


</div><div class="im"><div><br></div><div><br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
More than the number of lines of source in the module.<br>
And yet there are only 1305 asserts in that module -- the tests are not particularly comprehensive.<br>
<br>
</blockquote>
<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
-cov shows 96% coverage for std.algorithm</blockquote><div><br></div></div><div>Yeah, my point was that for N tests, we get O(N^^2) templates instantiated.<br></div><br></div></div></div>
<br>_______________________________________________<br>
dmd-internals mailing list<br>
<a href="mailto:dmd-internals@puremagic.com">dmd-internals@puremagic.com</a><br>
<a href="http://lists.puremagic.com/mailman/listinfo/dmd-internals" target="_blank">http://lists.puremagic.com/mailman/listinfo/dmd-internals</a><br></blockquote></div><br></div>