kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [1/2] kudu git commit: rpc: cache call deadline in InboundCall
Date Mon, 23 Apr 2018 22:45:51 GMT
Repository: kudu
Updated Branches:
  refs/heads/master b69f288e9 -> 1a3911c2e


rpc: cache call deadline in InboundCall

The call deadline is used when queueing a call in the service queue.
Previously, we recomputed the deadline from a non-inlined function
every time it was needed, which hurt the performance of queueing.

To test, I set the number of worker threads to only 2 to ensure
that a lot of calls were hitting the queue itself instead of the
direct hand-off path. I ran this both before and after two times each,
alternatingly:

  rpc-bench --worker_threads=2 --client_threads=24 \
    --async_call_concurrency=100 --server_reactors=24 --run_seconds=2 \
    --gtest_filter=\*Calls --gtest_repeat=30 \

I then grepped out the 'Reqs/sec' and ran a t-test using R:

> t.test(d.before$V1, d.after$V1)

        Welch Two Sample t-test

data:  d.before$V1 and d.after$V1
t = -5.3229, df = 113.94, p-value = 5.182e-07
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -11997.452  -5489.415
sample estimates:
mean of x mean of y
 375830.2  384573.6

So, with 95% confidence this improves throughput by at least 1.5%.

Oddly, the user CPU, system CPU, and context switch rate didn't show any
statistically significant difference, but the throughput difference was
clear.

Change-Id: I72138b4dcee6db105bbf9499961c4c1e8c26bd3f
Reviewed-on: http://gerrit.cloudera.org:8080/2942
Reviewed-by: Adar Dembo <adar@cloudera.com>
Tested-by: Todd Lipcon <todd@apache.org>


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

Branch: refs/heads/master
Commit: 4b75386342c05fe43df69924f04e05c435f685d0
Parents: b69f288
Author: Todd Lipcon <todd@apache.org>
Authored: Mon Apr 23 14:02:34 2018 -0700
Committer: Todd Lipcon <todd@apache.org>
Committed: Mon Apr 23 22:41:20 2018 +0000

----------------------------------------------------------------------
 src/kudu/rpc/inbound_call.cc | 23 ++++++++---------------
 src/kudu/rpc/inbound_call.h  |  8 +++++++-
 2 files changed, 15 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/4b753863/src/kudu/rpc/inbound_call.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/inbound_call.cc b/src/kudu/rpc/inbound_call.cc
index 44b5ec2..6920071 100644
--- a/src/kudu/rpc/inbound_call.cc
+++ b/src/kudu/rpc/inbound_call.cc
@@ -59,7 +59,8 @@ namespace rpc {
 InboundCall::InboundCall(Connection* conn)
   : conn_(conn),
     trace_(new Trace),
-    method_info_(nullptr) {
+    method_info_(nullptr),
+    deadline_(MonoTime::Max()) {
   RecordCallReceived();
 }
 
@@ -80,6 +81,11 @@ Status InboundCall::ParseFrom(gscoped_ptr<InboundTransfer> transfer)
{
   }
   remote_method_.FromPB(header_.remote_method());
 
+  // Compute and cache the call deadline.
+  if (header_.has_timeout_millis() && header_.timeout_millis() != 0) {
+    deadline_ = timing_.time_received + MonoDelta::FromMilliseconds(header_.timeout_millis());
+  }
+
   if (header_.sidecar_offsets_size() > TransferLimits::kMaxSidecars) {
     return Status::Corruption(strings::Substitute(
             "Received $0 additional payload slices, expected at most %d",
@@ -301,20 +307,7 @@ void InboundCall::RecordHandlingCompleted() {
 }
 
 bool InboundCall::ClientTimedOut() const {
-  if (!header_.has_timeout_millis() || header_.timeout_millis() == 0) {
-    return false;
-  }
-
-  MonoTime now = MonoTime::Now();
-  int total_time = (now - timing_.time_received).ToMilliseconds();
-  return total_time > header_.timeout_millis();
-}
-
-MonoTime InboundCall::GetClientDeadline() const {
-  if (!header_.has_timeout_millis() || header_.timeout_millis() == 0) {
-    return MonoTime::Max();
-  }
-  return timing_.time_received + MonoDelta::FromMilliseconds(header_.timeout_millis());
+  return MonoTime::Now() >= deadline_;
 }
 
 MonoTime InboundCall::GetTimeReceived() const {

http://git-wip-us.apache.org/repos/asf/kudu/blob/4b753863/src/kudu/rpc/inbound_call.h
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/inbound_call.h b/src/kudu/rpc/inbound_call.h
index e4083de..0db4c37 100644
--- a/src/kudu/rpc/inbound_call.h
+++ b/src/kudu/rpc/inbound_call.h
@@ -185,7 +185,9 @@ class InboundCall {
   // Return an upper bound on the client timeout deadline. This does not
   // account for transmission delays between the client and the server.
   // If the client did not specify a deadline, returns MonoTime::Max().
-  MonoTime GetClientDeadline() const;
+  MonoTime GetClientDeadline() const {
+    return deadline_;
+  }
 
   // Return the time when this call was received.
   MonoTime GetTimeReceived() const;
@@ -271,6 +273,10 @@ class InboundCall {
   // per-method info such as tracing.
   scoped_refptr<RpcMethodInfo> method_info_;
 
+  // A time at which the client will time out, or MonoTime::Max if the
+  // client did not pass a timeout.
+  MonoTime deadline_;
+
   DISALLOW_COPY_AND_ASSIGN(InboundCall);
 };
 


Mime
View raw message