kadircet created this revision. kadircet added a reviewer: sammccall. Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, javed.absar, ilya-biryukov. Herald added a project: clang.
Expose AST cache access statistics. Instead of doing this we can also expose EventTracer::instant. Currently it is only accessible through trace::log, which only provides plaintext information. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D78429 Files: clang-tools-extra/clangd/TUScheduler.cpp Index: clang-tools-extra/clangd/TUScheduler.cpp =================================================================== --- clang-tools-extra/clangd/TUScheduler.cpp +++ clang-tools-extra/clangd/TUScheduler.cpp @@ -143,10 +143,14 @@ /// the cache anymore. If nullptr was cached for \p K, this function will /// return a null unique_ptr wrapped into an optional. llvm::Optional<std::unique_ptr<ParsedAST>> take(Key K) { + trace::Span Span("ASTCache"); std::unique_lock<std::mutex> Lock(Mut); auto Existing = findByKey(K); - if (Existing == LRU.end()) + if (Existing == LRU.end()) { + SPAN_ATTACH(Span, "Hit", false); return None; + } + SPAN_ATTACH(Span, "Hit", true); std::unique_ptr<ParsedAST> V = std::move(Existing->second); LRU.erase(Existing); // GCC 4.8 fails to compile `return V;`, as it tries to call the copy
Index: clang-tools-extra/clangd/TUScheduler.cpp =================================================================== --- clang-tools-extra/clangd/TUScheduler.cpp +++ clang-tools-extra/clangd/TUScheduler.cpp @@ -143,10 +143,14 @@ /// the cache anymore. If nullptr was cached for \p K, this function will /// return a null unique_ptr wrapped into an optional. llvm::Optional<std::unique_ptr<ParsedAST>> take(Key K) { + trace::Span Span("ASTCache"); std::unique_lock<std::mutex> Lock(Mut); auto Existing = findByKey(K); - if (Existing == LRU.end()) + if (Existing == LRU.end()) { + SPAN_ATTACH(Span, "Hit", false); return None; + } + SPAN_ATTACH(Span, "Hit", true); std::unique_ptr<ParsedAST> V = std::move(Existing->second); LRU.erase(Existing); // GCC 4.8 fails to compile `return V;`, as it tries to call the copy
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits