Repository: mesos
Updated Branches:
  refs/heads/master 4934eb77c -> 2e83009ef


Reduced copying of agent data during reregistration.


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

Branch: refs/heads/master
Commit: 2e83009ef4d10e1cbfb3a55c8adefe37b916f06a
Parents: 8b42280
Author: Dmitry Zhuk <[email protected]>
Authored: Wed Dec 6 10:45:14 2017 -0800
Committer: Michael Park <[email protected]>
Committed: Wed Dec 6 12:21:27 2017 -0800

----------------------------------------------------------------------
 src/master/master.cpp | 32 ++++++++++++++++----------------
 src/master/master.hpp | 10 ++++------
 2 files changed, 20 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2e83009e/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index d66f956..2fd66c0 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -6753,7 +6753,7 @@ void Master::__reregisterSlave(
   // master (those tasks were previously marked "unreachable", so they
   // should be removed from that collection).
   vector<Task> recoveredTasks;
-  foreach (const Task& task, tasks) {
+  foreach (Task& task, tasks) {
     const FrameworkID& frameworkId = task.framework_id();
 
     // Don't re-add tasks whose framework has been shutdown at the
@@ -6762,12 +6762,12 @@ void Master::__reregisterSlave(
       continue;
     }
 
-    recoveredTasks.push_back(task);
-
     Framework* framework = getFramework(frameworkId);
     if (framework != nullptr) {
       framework->unreachableTasks.erase(task.task_id());
     }
+
+    recoveredTasks.push_back(std::move(task));
   }
 
   Slave* slave = new Slave(
@@ -11147,27 +11147,27 @@ Slave::Slave(
     const UPID& _pid,
     const MachineID& _machineId,
     const string& _version,
-    const vector<SlaveInfo::Capability>& _capabilites,
+    vector<SlaveInfo::Capability> _capabilites,
     const Time& _registeredTime,
     vector<Resource> _checkpointedResources,
-    const hashmap<Option<ResourceProviderID>, UUID>& _resourceVersions,
-    const vector<ExecutorInfo>& executorInfos,
-    const vector<Task>& tasks)
+    hashmap<Option<ResourceProviderID>, UUID> _resourceVersions,
+    vector<ExecutorInfo> executorInfos,
+    vector<Task> tasks)
   : master(_master),
     id(_info.id()),
-    info(_info),
+    info(std::move(_info)),
     machineId(_machineId),
     pid(_pid),
     version(_version),
-    capabilities(_capabilites),
+    capabilities(std::move(_capabilites)),
     registeredTime(_registeredTime),
     connected(true),
     active(true),
-    checkpointedResources(_checkpointedResources),
+    checkpointedResources(std::move(_checkpointedResources)),
     observer(nullptr),
-    resourceVersions(_resourceVersions)
+    resourceVersions(std::move(_resourceVersions))
 {
-  CHECK(_info.has_id());
+  CHECK(info.has_id());
 
   Try<Resources> resources = applyCheckpointedResources(
       info.resources(),
@@ -11177,13 +11177,13 @@ Slave::Slave(
   CHECK_SOME(resources);
   totalResources = resources.get();
 
-  foreach (const ExecutorInfo& executorInfo, executorInfos) {
+  foreach (ExecutorInfo& executorInfo, executorInfos) {
     CHECK(executorInfo.has_framework_id());
-    addExecutor(executorInfo.framework_id(), executorInfo);
+    addExecutor(executorInfo.framework_id(), std::move(executorInfo));
   }
 
-  foreach (const Task& task, tasks) {
-    addTask(new Task(task));
+  foreach (Task& task, tasks) {
+    addTask(new Task(std::move(task)));
   }
 }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/2e83009e/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index acea507..2658312 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -121,14 +121,12 @@ struct Slave
         const process::UPID& _pid,
         const MachineID& _machineId,
         const std::string& _version,
-        const std::vector<SlaveInfo::Capability>& _capabilites,
+        std::vector<SlaveInfo::Capability> _capabilites,
         const process::Time& _registeredTime,
         std::vector<Resource> _checkpointedResources,
-        const hashmap<Option<ResourceProviderID>, UUID>& _resourceVersions,
-        const std::vector<ExecutorInfo>& executorInfos =
-          std::vector<ExecutorInfo>(),
-        const std::vector<Task>& tasks =
-          std::vector<Task>());
+        hashmap<Option<ResourceProviderID>, UUID> _resourceVersions,
+        std::vector<ExecutorInfo> executorInfos = std::vector<ExecutorInfo>(),
+        std::vector<Task> tasks = std::vector<Task>());
 
   ~Slave();
 

Reply via email to