<div dir="auto"><div><div class="gmail_extra"><div class="gmail_quote">On 19 Oct 2016 2:44 am, "Andy Gibbs" <<a href="mailto:andyg1001@hotmail.co.uk">andyg1001@hotmail.co.uk</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I have observed a massive performance regression when upgrading from clang 3.7<br>
to 3.9.  I have also checked that current tip-of-trunk seems to have this<br>
regression too.<br>
<br>
I have managed to isolate the patch at which the regression appeared as<br>
r248431 on 23rd Sept 2015.<br>
<br>
I have attached a simple test-case that demonstrates the problem rather<br>
effectively.<br>
<br>
Prior to r248431, this code would compile in under 20 seconds, consuming<br>
approx. 400Mb of memory.  GCC, for comparison, takes longer at around 50<br>
seconds on my machine but consumes only ~250Mb.<br>
<br>
Following patch r248431 and all the way up to tip-of-trunk, clang is<br>
terminated by the OOM handler due excessive memory usage in excess of 7<br>
Gigabytes!!!<br>
<br>
This seems a little unreasonable -- the test-code in question is a little<br>
pathological maybe but is designed to exploit template memoisation, so the<br>
excessive memory usage would imply to me that this memoisation is no longer<br>
working.<br></blockquote></div></div></div><div><br></div><div>That's not the problem. The issue is that this:</div><div><br></div><div>(sizeof...(Is) + Is)...<br></div><div><br></div><div>substitutes into the sizeof... subexpression once for each element of Is, which massively amplifies any change in the behaviour of sizeof...</div><div><br></div><div>r248431 changes our behaviour such that sizeof... now scans its parameter's expansion looking for unexpanded packs (which can appear if it's used inside an alias template), making the instantiation of that fragment quadratic in the size of the pack Is.</div><div><br></div><div>I'll take a look and see if we can handle this a bit better.</div><div><br></div><div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Is anyone else able to confirm my findings?  If so, I will raise this as a bug<br>
report.  Richard, I have copied you as the author of the patch in question<br>
(hope you don't mind!).<br>
<br>
Cheers,<br>
Andy<br>
<br>
</blockquote></div><br></div></div></div>