Seems reasonable and some profile data would help motivate/support/justify which bits are worth changing and which aren't<br><br><div class="gmail_quote"><div dir="ltr">On Sat, Dec 15, 2018, 8:27 AM Bruno Ricci via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
I have been looking at Decl::getASTContext and DeclContext::getParentASTContext,<br>
and it turns out that they are not that cheap.<br>
<br>
The reason for this is that they must walk back to the translation unit declaration<br>
along what is essentially a linked list. This is amplified by the fact that it does<br>
look like a simple getter and therefore is called extremely often (the most egregious<br>
case by far being DeclContext::lookup), even when most of the times the context is<br>
already easily available.<br>
<br>
To put some numbers on this I experimented with removing about half of the iterations<br>
in Decl::getTranslationUnitDecl. This gives a speed up of about 1% when parsing all<br>
of Boost. Extrapolating from this I get that about 1.5%-2% of the time spent<br>
parsing Boost is spent getting the ASTContext, which seems a bit unfortunate.<br>
<br>
Now to be clear 1.5%-2% is not that much, but the fix is simply to pass a ref to<br>
the ASTContext more often as a function parameter. The downside is that this would<br>
cause a some amount of churn in the C++ api. To be clear I am *not* suggesting<br>
removing all of the calls to Decl::getASTContext, but only removing the ones causing<br>
the most iterations in Decl::getTranslationUnitDecl (say the top 10 or 20).<br>
<br>
What do you think ?<br>
<br>
Bruno<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>