[PATCH] D92181: [clangd] NFC: Add client-side logging for remote index requests

Kirill Bobyrev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 26 07:47:59 PST 2020


kbobyrev created this revision.
kbobyrev added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
kbobyrev requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Figuring out whether the server is responding and debugging issues with remote
index setup is no easy task: add verbose logging for client side RPC requests
to relieve some pain.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92181

Files:
  clang-tools-extra/clangd/index/remote/Client.cpp


Index: clang-tools-extra/clangd/index/remote/Client.cpp
===================================================================
--- clang-tools-extra/clangd/index/remote/Client.cpp
+++ clang-tools-extra/clangd/index/remote/Client.cpp
@@ -42,10 +42,14 @@
     SPAN_ATTACH(Tracer, "Request", RPCRequest.DebugString());
     grpc::ClientContext Context;
     Context.AddMetadata("version", clang::getClangToolFullVersion("clangd"));
-    std::chrono::system_clock::time_point Deadline =
-        std::chrono::system_clock::now() + DeadlineWaitingTime;
+    const std::chrono::system_clock::time_point StartTime =
+        std::chrono::system_clock::now();
+    const std::chrono::system_clock::time_point Deadline =
+        StartTime + DeadlineWaitingTime;
     Context.set_deadline(Deadline);
     auto Reader = (Stub.get()->*RPCCall)(&Context, RPCRequest);
+    vlog("Sending RPC Request {0}: {1}", RequestT::descriptor()->name(),
+         RPCRequest.DebugString());
     ReplyT Reply;
     unsigned Successful = 0;
     unsigned FailedToParse = 0;
@@ -65,6 +69,11 @@
       Callback(*Response);
       ++Successful;
     }
+    const auto Millis = std::chrono::duration_cast<std::chrono::milliseconds>(
+                            std::chrono::system_clock::now() - StartTime)
+                            .count();
+    vlog("RPC Request {0} => OK: {1} results in {2}ms",
+         RequestT::descriptor()->name(), Successful, Millis);
     SPAN_ATTACH(Tracer, "Status", Reader->Finish().ok());
     SPAN_ATTACH(Tracer, "Successful", Successful);
     SPAN_ATTACH(Tracer, "Failed to parse", FailedToParse);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92181.307868.patch
Type: text/x-patch
Size: 1606 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201126/005ccb1d/attachment-0001.bin>


More information about the cfe-commits mailing list