<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><span style="color:rgb(34,34,34)">I'm not sure what you're trying to investigate here. You've forced the</span><br></div></div>
majority of the compile time to be used while processing the .cpp file<br>
rather than its includes, so modules is not going to help you much<br>
here.<br></blockquote><div><br></div><div>What I try to investigate: if there is a way to fool the modules cache to cache template instantiation. I understand that the modules system is about taking the ast of the headers and saving it to a file. During compilation of a unit the compiler glues that AST to the ast of the compilation unit. Again intuitively if I have template instantiation in the cache, that should be just "glued". For me if I have a </div><div><br></div><div>map8 a1;</div><div>map8 a2;</div><div>.....</div><div>.....</div><div><br></div><div>one hundreds of times, compilation should be almost equally fast as i would have only once, and should be equally fast if the instantiation is found in the modules cache.<br><br>But, whatoever hard I try to cache both libcxx and my header, no improvement. The cache is created, I can walk through the ast inside the cache, but no speedup.</div><div><br></div><div>For instance I created a simple header: </div><div><div>#include <string></div><div>#include <map></div><div><br></div><div>using namespace std;</div><div><br></div><div>typedef map<string, string> mymap0;</div><div>typedef map<mymap0, mymap0> mymap1;</div><div>typedef map<mymap1, mymap1> mymap2;</div><div>typedef map<mymap2, mymap2> mymap3;</div><div>typedef map<mymap3, mymap3> mymap4;</div><div>typedef map<mymap4, mymap4> mymap5;</div><div>typedef map<mymap5, mymap5> mymap6;</div><div>typedef map<mymap6, mymap6> mymap7;</div><div>typedef map<mymap7, mymap7> mymap8;</div><div><br></div><div>mymap0 m0;</div><div>mymap1 m1;</div><div>mymap2 m2;</div><div>mymap3 m3;</div><div>mymap4 m4;</div><div>mymap5 m5;</div><div>mymap6 m6;</div><div>~ <br><br></div></div><div><br></div><div>BTW: is there any other trick to force instantiation, without generating any text?</div><div><br></div><div><br></div><div>and the module.map:</div><div><br></div><div><div> module g2 {</div><div> header "g2.h"</div><div> export *</div><div> }</div></div><div><br></div><div>cat g2.cpp <br><br><div>#include "g2.h"</div><div><br></div><div>int main() {<br></div><div>mymap5 m0;</div><div>mymap5 n0;</div><div>m0=n0;</div><div>mymap5 m1;</div><div>mymap5 n1;</div></div><div>......</div><div>}</div><div><br></div><div>tried different variations with different typems mymap etc..</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span><br>
> for "one level" instantiation, without modules, clang seems to be a little<br>
> faster than gcc, but for i > 3. With modules compilation is much longer.<br>
<br>
</span>Including or excluding the one-time cost of building the module for<br>
your standard library? I'm seeing a speedup in this testcase by<br>
enabling modules (with an appropriately-modularized standard library);<br>
the proportion speedup decreases as i increases, as expected, since<br>
more of the time is outside the headers.<br></blockquote><div>are you talking about libcxx or standard C? Copied also the system headers into a separate directory and created the module file. I have also the modules map file for libcxx and I see the cache created for it. Building the cache I agree shall take time, but once the cache is built, for me even subsequent compilations take longer than without the modules system.</div><div><br></div><div>What does your test case contain? </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span><br>
</span>This is more interesting. I'd imagine that GCC is avoiding some of the<br>
exponential-time costs here; in particular, its overload resolution<br>
short-circuits template argument deduction if it gets an exact match<br>
from a non-template candidate, and that's probably happening in the<br>
map assignments.<br></blockquote><div><br></div><div>Well, I am afraid once people stretch a bit the dimensions of templates, might be bit disappointed. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span><br>
</span>No; modules is intended to reduce the costs of including headers. It<br>
does not reduce costs associated with template instantiations that are<br>
performed locally to your .cpp file. (If you instantiated map0, map1,<br>
and so on in a header, then it would help.)<br></blockquote><div><br></div><div>That is what I tried, but does not seem to work.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
In principle, we could extend the modules system with a template<br>
instantiation repository to cache the results of instantiating<br>
templates from modules, but I don't think anyone is working on, or<br>
planning, such a system for Clang at the moment.<br>
</blockquote></div><div class="gmail_extra"><br></div>bit pity... from my experience, it was rather the template instantiation that was causing long build times and not the preprocessing. <br><br><br><br clear="all"><div><br></div><br><div>rgrds,<br>mobi phil<br><br>being mobile, but including technology<br><a href="http://mobiphil.com" target="_blank">http://mobiphil.com</a></div>
</div></div>