<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">On Jun 21, 2018, at 9:16 PM, Duncan P. N. Exon Smith <<a href="mailto:dexonsmith@apple.com" class="">dexonsmith@apple.com</a>> wrote:<br class=""><div><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><div class=""><div style="direction: ltr;" class=""><blockquote type="cite" class=""><div class=""><div class=""><br class="">Something like this could definitely work, but most smallvectors are on the stack.  They are intentionally used when sizeof(smallvector) isn’t important, so I don’t think this optimization will pay off.<br class=""></div></div></blockquote><div style="direction: ltr;" class=""><br class=""></div><div style="direction: ltr;" class="">For better or worse (mostly worse), there are a ton of SmallVector fields in data structures, including some even nested inside other SmallVectors (e.g., see the cleanup in r235229).  Often these data structures are heap-allocated.</div></div></div></div></div></blockquote><div><br class=""></div><div>Egads, that seems like a big issue, and (most of the time, but perhaps not always) a misuse of SmallVector.  It seems that this should be fixed, instead of changing smallvector.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><div class=""><div style="direction: ltr;" class=""><blockquote type="cite" class=""><div class=""><div class="">Out of curiosity, what brings this up?<br class=""></div></div></blockquote><div style="direction: ltr;" class=""><br class=""></div><div style="direction: ltr;" class="">I've noticed that Clang is using more stack recently (we're seeing more crashes from template recursion; it seems the template recursion limit needs to shrink), and somehow that train of thought led to this.</div><div style="direction: ltr;" class=""><br class=""></div><div style="direction: ltr;" class="">I share your skepticism that it will help stack usage much, but SmallVector/SmallVectorImpl is so ubiquitous, it could help the heap a bit.  And if it doesn’t hurt runtime performance in practice, there’s no reason to fork the data structure.</div><div style="direction: ltr;" class=""><br class=""></div><div style="direction: ltr;" class="">If no one has measured before I might try it some time. </div></div></div></div></div></blockquote></div><br class=""><div class="">I’m not familiar with the modern structure of the code, but is there any chance these algorithms can be reworked to be iterative instead of recursive?  Shrinking individual frames may buy some time, but isn’t really a fix.</div><div class=""><br class=""></div><div class="">-Chris</div><div class=""><br class=""></div></body></html>