[llvm-branch-commits] [clang-tools-extra] 32e7a9c - Revert "[clangd] Log remote index connectivity status"

Kirill Bobyrev via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Dec 15 09:46:56 PST 2020


Author: Kirill Bobyrev
Date: 2020-12-15T18:42:42+01:00
New Revision: 32e7a9cab6412cb4bb5add5cb2d48be82e7d9f11

URL: https://github.com/llvm/llvm-project/commit/32e7a9cab6412cb4bb5add5cb2d48be82e7d9f11
DIFF: https://github.com/llvm/llvm-project/commit/32e7a9cab6412cb4bb5add5cb2d48be82e7d9f11.diff

LOG: Revert "[clangd] Log remote index connectivity status"

This reverts commit dcdef5b5b3df457566e7faf61e1e5789c42528d1.

This commit breaks clangd-ubuntu-tsan builds:
http://lab.llvm.org:8011/#builders/131/builds/1392

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/index/remote/Client.cpp b/clang-tools-extra/clangd/index/remote/Client.cpp
index 4720b20402e1..0387e65db7d0 100644
--- a/clang-tools-extra/clangd/index/remote/Client.cpp
+++ b/clang-tools-extra/clangd/index/remote/Client.cpp
@@ -19,40 +19,14 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 
-#include <atomic>
 #include <chrono>
-#include <memory>
 
 namespace clang {
 namespace clangd {
 namespace remote {
 namespace {
 
-llvm::StringRef toString(const grpc_connectivity_state &State) {
-  switch (State) {
-  case GRPC_CHANNEL_IDLE:
-    return "idle";
-  case GRPC_CHANNEL_CONNECTING:
-    return "connecting";
-  case GRPC_CHANNEL_READY:
-    return "ready";
-  case GRPC_CHANNEL_TRANSIENT_FAILURE:
-    return "transient failure";
-  case GRPC_CHANNEL_SHUTDOWN:
-    return "shutdown";
-  }
-  llvm_unreachable("Not a valid grpc_connectivity_state.");
-}
-
 class IndexClient : public clangd::SymbolIndex {
-  void updateConnectionStatus() const {
-    auto NewStatus = Channel->GetState(/*try_to_connect=*/false);
-    auto OldStatus = ConnectionStatus.exchange(NewStatus);
-    if (OldStatus != NewStatus)
-      vlog("Remote index connection [{0}]: {1} => {2}", ServerAddress,
-           toString(OldStatus), toString(NewStatus));
-  }
-
   template <typename RequestT, typename ReplyT>
   using StreamingCall = std::unique_ptr<grpc::ClientReader<ReplyT>> (
       remote::v1::SymbolIndex::Stub::*)(grpc::ClientContext *,
@@ -63,7 +37,6 @@ class IndexClient : public clangd::SymbolIndex {
   bool streamRPC(ClangdRequestT Request,
                  StreamingCall<RequestT, ReplyT> RPCCall,
                  CallbackT Callback) const {
-    updateConnectionStatus();
     bool FinalResult = false;
     trace::Span Tracer(RequestT::descriptor()->name());
     const auto RPCRequest = ProtobufMarshaller->toProtobuf(Request);
@@ -104,21 +77,18 @@ class IndexClient : public clangd::SymbolIndex {
     SPAN_ATTACH(Tracer, "Status", Reader->Finish().ok());
     SPAN_ATTACH(Tracer, "Successful", Successful);
     SPAN_ATTACH(Tracer, "Failed to parse", FailedToParse);
-    updateConnectionStatus();
     return FinalResult;
   }
 
 public:
   IndexClient(
-      std::shared_ptr<grpc::Channel> Channel, llvm::StringRef Address,
-      llvm::StringRef ProjectRoot,
+      std::shared_ptr<grpc::Channel> Channel, llvm::StringRef ProjectRoot,
+      llvm::StringRef Address,
       std::chrono::milliseconds DeadlineTime = std::chrono::milliseconds(1000))
-      : Stub(remote::v1::SymbolIndex::NewStub(Channel)), Channel(Channel),
-        ServerAddress(Address),
-        ConnectionStatus(Channel->GetState(/*try_to_connect=*/true)),
+      : Stub(remote::v1::SymbolIndex::NewStub(Channel)),
         ProtobufMarshaller(new Marshaller(/*RemoteIndexRoot=*/"",
                                           /*LocalIndexRoot=*/ProjectRoot)),
-        DeadlineWaitingTime(DeadlineTime) {
+        ServerAddress(Address), DeadlineWaitingTime(DeadlineTime) {
     assert(!ProjectRoot.empty());
   }
 
@@ -158,9 +128,6 @@ class IndexClient : public clangd::SymbolIndex {
 
 private:
   std::unique_ptr<remote::v1::SymbolIndex::Stub> Stub;
-  std::shared_ptr<grpc::Channel> Channel;
-  llvm::SmallString<256> ServerAddress;
-  mutable std::atomic<grpc_connectivity_state> ConnectionStatus;
   std::unique_ptr<Marshaller> ProtobufMarshaller;
   llvm::SmallString<256> ServerAddress;
   // Each request will be terminated if it takes too long.
@@ -173,8 +140,9 @@ std::unique_ptr<clangd::SymbolIndex> getClient(llvm::StringRef Address,
                                                llvm::StringRef ProjectRoot) {
   const auto Channel =
       grpc::CreateChannel(Address.str(), grpc::InsecureChannelCredentials());
+  Channel->GetState(true);
   return std::unique_ptr<clangd::SymbolIndex>(
-      new IndexClient(Channel, Address, ProjectRoot));
+      new IndexClient(Channel, ProjectRoot, Address));
 }
 
 } // namespace remote


        


More information about the llvm-branch-commits mailing list