[clang-tools-extra] [clang-doc] Improve performance by adding a short circuit (PR #96809)

via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 29 02:14:35 PDT 2024


PeterChou1 wrote:

CC: @sam-mccall
I was told by @ilovepi and @petrhosek that you might have same insights with libtooling/clang

We are currently facing some performance issues with clang-doc (a documentation generator built on top of libtooling). The problem we're having is that it can take up to 10 hours from clang-doc to run through LLVM compilation database, whereas other tools similar tools can do this much faster.
Currently clang-doc uses RecursiveASTVisitor to visit every relevant decl and serializes it into a custom bitcode which it then deserializes later to generate the docs.  The problem is that there is a lot of redundant computation when the ASTVisitor does the traversal, as the same declaration can be visited multiple times. Sometimes clang-doc wants to visit a decl multiple times so we can merge the comments in the declaration and definition. But other times we don't this behaviour such as when ASTVisitor visits a parent class from a derived class and we've already visited the parent already. 
I added the above patch to try to cut down on redundant computation. This patch works, and cuts down on the computation of clang-doc significantly however this their is a slight difference between the generated output from this patch, and the main branch. Which is why we're hesitant to land this patch as, we don't fully understand what the effect this patch will have. 

Is there a better way to approach this?  

https://github.com/llvm/llvm-project/pull/96809


More information about the cfe-commits mailing list