Repository: kudu
Updated Branches:
  refs/heads/master 2b0c1c019 -> 40ba6c143


[consensus_peers] micro-optimization on controller status

While running raft_consensus_stress-itest where a lot of RPC fail,
I found the following stats for operator new[](unsigned long)
in tserver with regard of Status::CopyState():

-   1.13%  kudu-tserver  libtcmalloc.so.4.5.1            [.] operator 
new[](unsigned long)
   - operator new[](unsigned long)
      ...
      + 3.21% kudu::Status::CopyState(char const*)
           kudu::Status::Status(kudu::Status const&)
           kudu::rpc::OutboundCall::status() const
           kudu::rpc::RpcController::status() const
           kudu::consensus::Peer::ProcessResponse()
      ...

Of course, that's not in the hot path in case of success scenarios,
but I think it makes sense to add these micro-optimizations.

Change-Id: I25ac21db191a21f3bdfb3378e32fbe366d98297c
Reviewed-on: http://gerrit.cloudera.org:8080/9387
Tested-by: Kudu Jenkins
Reviewed-by: Andrew Wong <aw...@cloudera.com>
Reviewed-by: Todd Lipcon <t...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/b0dc9ea9
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/b0dc9ea9
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/b0dc9ea9

Branch: refs/heads/master
Commit: b0dc9ea903365d54b9daf9c1b53d8ab2cc921fa6
Parents: 2b0c1c0
Author: Alexey Serbin <aser...@cloudera.com>
Authored: Wed Feb 21 14:26:31 2018 -0800
Committer: Alexey Serbin <aser...@cloudera.com>
Committed: Thu Feb 22 20:56:31 2018 +0000

----------------------------------------------------------------------
 src/kudu/consensus/consensus_peers.cc | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/b0dc9ea9/src/kudu/consensus/consensus_peers.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus_peers.cc 
b/src/kudu/consensus/consensus_peers.cc
index 26c302a..4724ad9 100644
--- a/src/kudu/consensus/consensus_peers.cc
+++ b/src/kudu/consensus/consensus_peers.cc
@@ -297,11 +297,12 @@ void Peer::ProcessResponse() {
   MAYBE_FAULT(FLAGS_fault_crash_after_leader_request_fraction);
 
   // Process RpcController errors.
-  if (!controller_.status().ok()) {
-    auto ps = controller_.status().IsRemoteError() ?
+  const auto controller_status = controller_.status();
+  if (!controller_status.ok()) {
+    auto ps = controller_status.IsRemoteError() ?
         PeerStatus::REMOTE_ERROR : PeerStatus::RPC_LAYER_ERROR;
-    queue_->UpdatePeerStatus(peer_pb_.permanent_uuid(), ps, 
controller_.status());
-    ProcessResponseError(controller_.status());
+    queue_->UpdatePeerStatus(peer_pb_.permanent_uuid(), ps, controller_status);
+    ProcessResponseError(controller_status);
     return;
   }
 
@@ -404,8 +405,9 @@ void Peer::ProcessTabletCopyResponse() {
   request_pending_ = false;
 
   // If the response is OK, or ALREADY_INPROGRESS, then consider the RPC 
successful.
+  const auto controller_status = controller_.status();
   bool success =
-    controller_.status().ok() &&
+    controller_status.ok() &&
     (!tc_response_.has_error() ||
      tc_response_.error().code() == 
TabletServerErrorPB::TabletServerErrorPB::ALREADY_INPROGRESS);
 
@@ -417,9 +419,9 @@ void Peer::ProcessTabletCopyResponse() {
     // THROTTLED is a common response after a tserver with many replicas fails;
     // logging it would generate a great deal of log spam.
     LOG_WITH_PREFIX_UNLOCKED(WARNING) << "Unable to begin Tablet Copy on peer: 
"
-                                      << (controller_.status().ok() ?
+                                      << (controller_status.ok() ?
                                           SecureShortDebugString(tc_response_) 
:
-                                          controller_.status().ToString());
+                                          controller_status.ToString());
   }
 }
 

Reply via email to