<div dir="ltr">Ah, I was hoping/looking for more of a timing/cpu-counter type profile, to demonstrate the overall impact (% runtime) of these changes, if possible?</div><br><div class="gmail_quote"><div dir="ltr">On Sat, Dec 15, 2018 at 9:57 AM Bruno Ricci <<a href="mailto:riccibrun@gmail.com">riccibrun@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I have added the profile data to the first patch (<a href="https://reviews.llvm.org/D55658" rel="noreferrer" target="_blank">https://reviews.llvm.org/D55658</a>)<br>
<br>
The top 20 callers of getASTContext and getParentASTContext are:<br>
(with the number of calls to getTranslationUnitDecl, edited for readability)<br>
<br>
5399586 : DeclContext::lookup<br>
801684 : VarDecl::getMemberSpecializationInfo<br>
551928 : FunctionDecl::getMinRequiredArguments<br>
401464 : CXXRecordDecl::lookupInBases<br>
338614 : Decl::getAttrs<br>
311651 : DeclContext::makeDeclVisibleInContextImpl<br>
173684 : Decl::getASTMutationListener<br>
164264 : CXXConstructorDecl::isSpecializationCopyingObject<br>
154066 : CXXMethodDecl::size_overridden_methods<br>
141622 : CXXRecordDecl::getVisibleConversionFunctions<br>
120440 : ClassTemplateSpecializationDecl::Profile<br>
116303 : VarDecl::isThisDeclarationADefinition<br>
106208 : CXXRecordDecl::conversion_begin<br>
106208 : CXXRecordDecl::conversion_end<br>
99075 : FunctionDecl::setParams<br>
95910 : RedeclarableTemplateDecl::findSpecializationImpl<br>
57043 : CXXRecordDecl::getDestructor<br>
56668 : VarDecl::getDefinition<br>
52140 : TagDecl::startDefinition<br>
48266 : CXXConstructorDecl::isCopyOrMoveConstructor<br>
37407 : FunctionDecl::getBody<br>
<br>
Bruno<br>
<br>
On 15/12/2018 16:38, David Blaikie wrote:<br>
> Seems reasonable and some profile data would help motivate/support/justify which bits are worth changing and which aren't<br>
> <br>
> On Sat, Dec 15, 2018, 8:27 AM Bruno Ricci via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a> <mailto:<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br>
> <br>
> 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> <mailto:<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>
> <br>
</blockquote></div>