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 2018/03/21 17:57:32 UTC
mesos git commit: Updated task reconciliation path to avoid copying
in v1.
Repository: mesos
Updated Branches:
refs/heads/master 5d8a9c1b7 -> 7660eb534
Updated task reconciliation path to avoid copying in v1.
This enforces the pattern of v0 messages converting to a v1
message and passing through the v1 logic.
>From a performance perspective, the v1 path no longer copies into
a `vector<TaskStatus>` which should offer improved performance.
In the v0 path, we now move into a `Reconcile` message rather than
moving into a `vector<TaskStatus>`. Therefore, this improves v1
performance while keeping v0 performance roughly the same in terms
of copying.
Review: https://reviews.apache.org/r/66004
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/7660eb53
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/7660eb53
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/7660eb53
Branch: refs/heads/master
Commit: 7660eb53460c1e0b350291da216901602ca28faf
Parents: 5d8a9c1
Author: Benjamin Mahler <bm...@apache.org>
Authored: Fri Mar 9 13:47:01 2018 -0800
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Wed Mar 21 10:56:54 2018 -0700
----------------------------------------------------------------------
src/master/http.cpp | 2 +-
src/master/master.cpp | 93 +++++++++++++++++++++-------------------------
src/master/master.hpp | 11 +-----
3 files changed, 46 insertions(+), 60 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/7660eb53/src/master/http.cpp
----------------------------------------------------------------------
diff --git a/src/master/http.cpp b/src/master/http.cpp
index e0742f9..f84089e 100644
--- a/src/master/http.cpp
+++ b/src/master/http.cpp
@@ -1106,7 +1106,7 @@ Future<Response> Master::Http::scheduler(
return Forbidden("Operation status updates are not yet implemented");
case scheduler::Call::RECONCILE:
- master->reconcile(framework, call.reconcile());
+ master->reconcile(framework, std::move(*call.mutable_reconcile()));
return Accepted();
// TODO(greggomann): Implement operation reconciliation.
http://git-wip-us.apache.org/repos/asf/mesos/blob/7660eb53/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 78f16d6..491fdad 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -864,9 +864,7 @@ void Master::initialize()
&Master::executorMessage);
install<ReconcileTasksMessage>(
- &Master::reconcileTasks,
- &ReconcileTasksMessage::framework_id,
- &ReconcileTasksMessage::statuses);
+ &Master::reconcileTasks);
install<UpdateOperationStatusMessage>(
&Master::updateOperationStatus);
@@ -2423,7 +2421,7 @@ void Master::receive(
}
case scheduler::Call::RECONCILE:
- reconcile(framework, call.reconcile());
+ reconcile(framework, std::move(*call.mutable_reconcile()));
break;
case scheduler::Call::RECONCILE_OPERATIONS:
@@ -5707,13 +5705,16 @@ void Master::kill(Framework* framework, const scheduler::Call::Kill& kill)
<< " of framework " << *framework
<< " because it is unknown; performing reconciliation";
- TaskStatus status;
- status.mutable_task_id()->CopyFrom(taskId);
+ scheduler::Call::Reconcile message;
+ scheduler::Call::Reconcile::Task* t = message.add_tasks();
+
+ *t->mutable_task_id() = taskId;
+
if (slaveId.isSome()) {
- status.mutable_slave_id()->CopyFrom(slaveId.get());
+ *t->mutable_slave_id() = slaveId.get();
}
- _reconcileTasks(framework, {status});
+ reconcile(framework, std::move(message));
return;
}
@@ -8339,34 +8340,12 @@ void Master::markGone(Slave* slave, const TimeInfo& goneTime)
}
-void Master::reconcile(
- Framework* framework,
- const scheduler::Call::Reconcile& reconcile)
-{
- CHECK_NOTNULL(framework);
-
- // Construct 'TaskStatus'es from 'Reconcile::Task's.
- vector<TaskStatus> statuses;
- foreach (const scheduler::Call::Reconcile::Task& task, reconcile.tasks()) {
- TaskStatus status;
- status.mutable_task_id()->CopyFrom(task.task_id());
- status.set_state(TASK_RUNNING); // Dummy status.
- if (task.has_slave_id()) {
- status.mutable_slave_id()->CopyFrom(task.slave_id());
- }
-
- statuses.push_back(status);
- }
-
- _reconcileTasks(framework, statuses);
-}
-
-
void Master::reconcileTasks(
const UPID& from,
- const FrameworkID& frameworkId,
- const vector<TaskStatus>& statuses)
+ ReconcileTasksMessage&& reconcileTasksMessage)
{
+ const FrameworkID& frameworkId = reconcileTasksMessage.framework_id();
+
Framework* framework = getFramework(frameworkId);
if (framework == nullptr) {
LOG(WARNING) << "Unknown framework " << frameworkId << " at " << from
@@ -8383,19 +8362,32 @@ void Master::reconcileTasks(
return;
}
- _reconcileTasks(framework, statuses);
+ scheduler::Call::Reconcile message;
+ message.mutable_tasks()->Reserve(reconcileTasksMessage.statuses_size());
+
+ foreach (TaskStatus& status, *reconcileTasksMessage.mutable_statuses()) {
+ scheduler::Call::Reconcile::Task* t = message.add_tasks();
+
+ *t->mutable_task_id() = std::move(status.task_id());
+
+ if (status.has_slave_id()) {
+ *t->mutable_slave_id() = std::move(status.slave_id());
+ }
+ }
+
+ reconcile(framework, std::move(message));
}
-void Master::_reconcileTasks(
+void Master::reconcile(
Framework* framework,
- const vector<TaskStatus>& statuses)
+ scheduler::Call::Reconcile&& reconcile)
{
CHECK_NOTNULL(framework);
++metrics->messages_reconcile_tasks;
- if (statuses.empty()) {
+ if (reconcile.tasks().empty()) {
// Implicit reconciliation.
LOG(INFO) << "Performing implicit task state reconciliation"
" for framework " << *framework;
@@ -8463,8 +8455,9 @@ void Master::_reconcileTasks(
}
// Explicit reconciliation.
- LOG(INFO) << "Performing explicit task state reconciliation for "
- << statuses.size() << " tasks of framework " << *framework;
+ LOG(INFO) << "Performing explicit task state reconciliation"
+ << " for " << reconcile.tasks().size() << " tasks"
+ << " of framework " << *framework;
// Explicit reconciliation occurs for the following cases:
// (1) Task is known, but pending: TASK_STAGING.
@@ -8482,18 +8475,18 @@ void Master::_reconcileTasks(
//
// For cases (4), (5), (6) and (7) TASK_LOST is sent instead if the
// framework has not opted-in to the PARTITION_AWARE capability.
- foreach (const TaskStatus& status, statuses) {
+ foreach (const scheduler::Call::Reconcile::Task& t, reconcile.tasks()) {
Option<SlaveID> slaveId = None();
- if (status.has_slave_id()) {
- slaveId = status.slave_id();
+ if (t.has_slave_id()) {
+ slaveId = t.slave_id();
}
Option<StatusUpdate> update = None();
- Task* task = framework->getTask(status.task_id());
+ Task* task = framework->getTask(t.task_id());
- if (framework->pendingTasks.contains(status.task_id())) {
+ if (framework->pendingTasks.contains(t.task_id())) {
// (1) Task is known, but pending: TASK_STAGING.
- const TaskInfo& task_ = framework->pendingTasks[status.task_id()];
+ const TaskInfo& task_ = framework->pendingTasks[t.task_id()];
update = protobuf::createStatusUpdate(
framework->id(),
task_.slave_id(),
@@ -8533,7 +8526,7 @@ void Master::_reconcileTasks(
// will have to retry this and will not receive a response until
// the agent either registers, or is marked unreachable after the
// timeout.
- LOG(INFO) << "Dropping reconciliation of task " << status.task_id()
+ LOG(INFO) << "Dropping reconciliation of task " << t.task_id()
<< " for framework " << *framework << " because "
<< (slaveId.isSome() ?
"agent " + stringify(slaveId.get()) + " has" :
@@ -8551,7 +8544,7 @@ void Master::_reconcileTasks(
update = protobuf::createStatusUpdate(
framework->id(),
slaveId.get(),
- status.task_id(),
+ t.task_id(),
taskState,
TaskStatus::SOURCE_MASTER,
None(),
@@ -8572,7 +8565,7 @@ void Master::_reconcileTasks(
update = protobuf::createStatusUpdate(
framework->id(),
slaveId.get(),
- status.task_id(),
+ t.task_id(),
taskState,
TaskStatus::SOURCE_MASTER,
None(),
@@ -8596,7 +8589,7 @@ void Master::_reconcileTasks(
update = protobuf::createStatusUpdate(
framework->id(),
slaveId.get(),
- status.task_id(),
+ t.task_id(),
taskState,
TaskStatus::SOURCE_MASTER,
None(),
@@ -8614,7 +8607,7 @@ void Master::_reconcileTasks(
update = protobuf::createStatusUpdate(
framework->id(),
slaveId,
- status.task_id(),
+ t.task_id(),
taskState,
TaskStatus::SOURCE_MASTER,
None(),
http://git-wip-us.apache.org/repos/asf/mesos/blob/7660eb53/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index a54b8fa..7e5d1df 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -508,8 +508,7 @@ public:
void reconcileTasks(
const process::UPID& from,
- const FrameworkID& frameworkId,
- const std::vector<TaskStatus>& statuses);
+ ReconcileTasksMessage&& reconcileTasksMessage);
void updateOperationStatus(
const UpdateOperationStatusMessage& update);
@@ -666,12 +665,6 @@ protected:
// Invoked when the contender has entered the contest.
void contended(const process::Future<process::Future<Nothing>>& candidacy);
- // Task reconciliation, split from the message handler
- // to allow re-use.
- void _reconcileTasks(
- Framework* framework,
- const std::vector<TaskStatus>& statuses);
-
// When a slave that was previously registered with this master
// reregisters, we need to reconcile the master's view of the
// slave's tasks and executors. This function also sends the
@@ -1081,7 +1074,7 @@ private:
void reconcile(
Framework* framework,
- const scheduler::Call::Reconcile& reconcile);
+ scheduler::Call::Reconcile&& reconcile);
void reconcileOperations(
Framework* framework,