You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2017/11/07 18:59:55 UTC

[1/3] mesos git commit: Avoid an extra copy during ProtobufProcess::send.

Repository: mesos
Updated Branches:
  refs/heads/master 509a1ab32 -> f5e1c928b


Avoid an extra copy during ProtobufProcess::send.

Review: https://reviews.apache.org/r/63606


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

Branch: refs/heads/master
Commit: f5e1c928b0e3d256b7b5a212c111b603fea1aa81
Parents: 3ca7a2f
Author: Benjamin Mahler <bm...@apache.org>
Authored: Mon Nov 6 18:51:29 2017 -0800
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Tue Nov 7 10:59:28 2017 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/protobuf.hpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/f5e1c928/3rdparty/libprocess/include/process/protobuf.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/protobuf.hpp b/3rdparty/libprocess/include/process/protobuf.hpp
index 81f7134..5b9794f 100644
--- a/3rdparty/libprocess/include/process/protobuf.hpp
+++ b/3rdparty/libprocess/include/process/protobuf.hpp
@@ -110,8 +110,7 @@ protected:
   {
     std::string data;
     message.SerializeToString(&data);
-    process::Process<T>::send(to, message.GetTypeName(),
-                              data.data(), data.size());
+    process::Process<T>::send(to, message.GetTypeName(), std::move(data));
   }
 
   using process::Process<T>::send;


[3/3] mesos git commit: Removed an unnecessary serialization in protobuf process.

Posted by bm...@apache.org.
Removed an unnecessary serialization in protobuf process.

Review: https://reviews.apache.org/r/63604


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

Branch: refs/heads/master
Commit: ad3245c5c472b8bea2cafa082e48a925668eb2d6
Parents: 509a1ab
Author: Benjamin Mahler <bm...@apache.org>
Authored: Mon Nov 6 18:04:44 2017 -0800
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Tue Nov 7 10:59:28 2017 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/protobuf.hpp | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ad3245c5/3rdparty/libprocess/include/process/protobuf.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/protobuf.hpp b/3rdparty/libprocess/include/process/protobuf.hpp
index fe152f2..81f7134 100644
--- a/3rdparty/libprocess/include/process/protobuf.hpp
+++ b/3rdparty/libprocess/include/process/protobuf.hpp
@@ -119,8 +119,6 @@ protected:
   void reply(const google::protobuf::Message& message)
   {
     CHECK(from) << "Attempting to reply without a sender";
-    std::string data;
-    message.SerializeToString(&data);
     send(from, message);
   }
 


[2/3] mesos git commit: Support moving in data during ProcessBase::send.

Posted by bm...@apache.org.
Support moving in data during ProcessBase::send.

This allows callers that can move in data to avoid an extra copy.

Review: https://reviews.apache.org/r/63605


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

Branch: refs/heads/master
Commit: 3ca7a2fe5f0706b619bb0343827d81f4e336e70d
Parents: ad3245c
Author: Benjamin Mahler <bm...@apache.org>
Authored: Mon Nov 6 18:50:56 2017 -0800
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Tue Nov 7 10:59:28 2017 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/event.hpp   |  5 +--
 3rdparty/libprocess/include/process/process.hpp | 10 +++--
 3rdparty/libprocess/src/process.cpp             | 45 +++++++-------------
 3rdparty/libprocess/src/tests/benchmarks.cpp    |  6 +--
 3rdparty/libprocess/src/tests/process_tests.cpp |  2 +-
 5 files changed, 29 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/3ca7a2fe/3rdparty/libprocess/include/process/event.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/event.hpp b/3rdparty/libprocess/include/process/event.hpp
index 2e24620..571ffb1 100644
--- a/3rdparty/libprocess/include/process/event.hpp
+++ b/3rdparty/libprocess/include/process/event.hpp
@@ -105,9 +105,8 @@ struct MessageEvent : Event
       const UPID& from,
       const UPID& to,
       std::string&& name,
-      const char* data,
-      size_t length)
-    : message{std::move(name), from, to, std::string(data, length)} {}
+      std::string&& data)
+    : message{std::move(name), from, to, std::move(data)} {}
 
   MessageEvent(const MessageEvent& that) = default;
   MessageEvent(MessageEvent&& that) = default;

http://git-wip-us.apache.org/repos/asf/mesos/blob/3ca7a2fe/3rdparty/libprocess/include/process/process.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/process.hpp b/3rdparty/libprocess/include/process/process.hpp
index dc3375c..d88c2f2 100644
--- a/3rdparty/libprocess/include/process/process.hpp
+++ b/3rdparty/libprocess/include/process/process.hpp
@@ -133,7 +133,8 @@ protected:
   virtual void lost(const UPID&) {}
 
   /**
-   * Sends the message to the specified `UPID`.
+   * Sends the message to the specified `UPID`. Prefer the rvalue
+   * reference overloads if the data can be moved in.
    *
    * @see process::Message
    */
@@ -145,9 +146,12 @@ protected:
 
   void send(
       const UPID& to,
+      std::string&& name);
+
+  void send(
+      const UPID& to,
       std::string&& name,
-      const char* data = nullptr,
-      size_t length = 0);
+      std::string&& data);
 
   /**
    * Describes the behavior of the `link` call when the target `pid`

http://git-wip-us.apache.org/repos/asf/mesos/blob/3ca7a2fe/3rdparty/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp
index 71ae712..732aff8 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -755,23 +755,10 @@ void Clock::settle()
 static Message encode(
     const UPID& from,
     const UPID& to,
-    const string& name,
-    const char* data,
-    size_t length)
-{
-  Message message{name, from, to, string(data, length)};
-  return message;
-}
-
-
-static Message encode(
-    const UPID& from,
-    const UPID& to,
     string&& name,
-    const char* data,
-    size_t length)
+    string&& data)
 {
-  Message message{std::move(name), from, to, string(data, length)};
+  Message message{std::move(name), from, to, std::move(data)};
   return message;
 }
 
@@ -809,7 +796,7 @@ static void transport(
     process_manager->deliver(event->message.to, event, sender);
   } else {
     // Remote message.
-    socket_manager->send(encode(from, to, name, data, length));
+    socket_manager->send(encode(from, to, string(name), string(data, length)));
   }
 }
 
@@ -818,8 +805,7 @@ static void transport(
     const UPID& from,
     const UPID& to,
     string&& name,
-    const char* data,
-    size_t length,
+    string&& data,
     ProcessBase* sender = nullptr)
 {
   if (to.address == __address__) {
@@ -828,13 +814,12 @@ static void transport(
         from,
         to,
         std::move(name),
-        data,
-        length);
+        std::move(data));
 
     process_manager->deliver(event->message.to, event, sender);
   } else {
     // Remote message.
-    socket_manager->send(encode(from, to, std::move(name), data, length));
+    socket_manager->send(encode(from, to, std::move(name), std::move(data)));
   }
 }
 
@@ -3887,27 +3872,29 @@ void ProcessBase::send(
     const char* data,
     size_t length)
 {
-  if (!to) {
-    return;
-  }
+  send(to, string(name), string(data, length));
+}
 
-  // Encode and transport outgoing message.
-  transport(pid, to, name, data, length, this);
+
+void ProcessBase::send(
+    const UPID& to,
+    string&& name)
+{
+  send(to, std::move(name), string());
 }
 
 
 void ProcessBase::send(
     const UPID& to,
     string&& name,
-    const char* data,
-    size_t length)
+    string&& data)
 {
   if (!to) {
     return;
   }
 
   // Encode and transport outgoing message.
-  transport(pid, to, std::move(name), data, length, this);
+  transport(pid, to, std::move(name), std::move(data), this);
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/3ca7a2fe/3rdparty/libprocess/src/tests/benchmarks.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/benchmarks.cpp b/3rdparty/libprocess/src/tests/benchmarks.cpp
index e6c77d5..2c6de62 100644
--- a/3rdparty/libprocess/src/tests/benchmarks.cpp
+++ b/3rdparty/libprocess/src/tests/benchmarks.cpp
@@ -209,6 +209,7 @@ public:
 protected:
   virtual void initialize()
   {
+    // TODO(bmahler): Move in the message when move support is added.
     install("ping", &ServerProcess::ping);
   }
 
@@ -605,8 +606,7 @@ public:
     bool success = message.SerializeToString(&data);
     CHECK(success);
 
-    MessageEvent event(self(), self(), message.GetTypeName(),
-        data.c_str(), data.length());
+    MessageEvent event(self(), self(), message.GetTypeName(), std::move(data));
 
     Stopwatch watch;
     watch.start();
@@ -621,7 +621,7 @@ public:
 
     double messagesPerSecond = count / watch.elapsed().secs();
 
-    cout << "Size: " << std::setw(5) << data.length() << " bytes,"
+    cout << "Size: " << std::setw(5) << message.ByteSizeLong() << " bytes,"
          << " throughput: " << std::setw(9) << std::setprecision(0)
          << std::fixed << messagesPerSecond << " messages/s" << endl;
   }

http://git-wip-us.apache.org/repos/asf/mesos/blob/3ca7a2fe/3rdparty/libprocess/src/tests/process_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/process_tests.cpp b/3rdparty/libprocess/src/tests/process_tests.cpp
index 952c92c..d1b30b0 100644
--- a/3rdparty/libprocess/src/tests/process_tests.cpp
+++ b/3rdparty/libprocess/src/tests/process_tests.cpp
@@ -829,7 +829,7 @@ public:
 
   void ping_linkee()
   {
-    send(pid, "whatever", "", 0);
+    send(pid, "whatever");
   }
 
   MOCK_METHOD1(exited, void(const UPID&));