[PATCH] D78429: [clangd] Trace ASTCache accesses

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 18 08:05:04 PDT 2020


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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78429.258523.patch
Type: text/x-patch
Size: 874 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200418/128e3776/attachment.bin>


More information about the cfe-commits mailing list