[PATCH] D55658: Avoid Decl::getASTContext in hot paths where possible, Part 1

Bruno Ricci via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 14 08:00:35 PST 2018


riccibruno added a comment.

Just to expend on the instrumentation results: The measurement was done with all of Boost. I would take the estimation of the time wasted with
a grain of salt since this is just `num_iterations * 10ns` which is obviously a very rough estimation.
However on my machine I get that removing half of the iterations in `getTranslationUnitDecl` reduce the run-time of an fsyntax-only by a little more than 1%.

Extrapolating from this, this could be worth about 2% if we remove, say 80%, of the iterations in `getTranslationUnitDecl`.

I guess that the question is: Is this churn worth about 2% ? I would like to argue that yes since:

1. 2% is a lot for something that is morally a simple getter.
2. The methods of the expression classes must already take a ref to the `ASTContext` if they need it.
3. In the vast majority of cases the context is already easily available. It is true though that this requires propagating it in some functions.
4. This figure do not include some potential gains in the time needed to do the AST -> LLVM IR code generation.
5. I suspect (but have not done the measurement) that the gain is even greater during a typical compilation where more than one thread is used since possibly more iterations are going to cause an expensive LLC miss.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55658/new/

https://reviews.llvm.org/D55658





More information about the cfe-commits mailing list