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/22 19:02:47 UTC

mesos git commit: Optimized resources logging in master.

Repository: mesos
Updated Branches:
  refs/heads/master a006924f8 -> 8ea9245e5


Optimized resources logging in master.

When master logs agent or task resources, it uses `operator <<` for raw
protobuf data, which outputs resources in JSON format, and is rather
slow. However resources are known to be valid and refined when logged by
master, so it's faster to use `operator <<` after protobuf is converted
to `Resources`.

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


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

Branch: refs/heads/master
Commit: 8ea9245e5c6d1f8b84219eb5d8b36f3cec1c6a7a
Parents: a006924
Author: Dmitry Zhuk <dz...@twopensource.com>
Authored: Wed Nov 22 11:59:17 2017 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Wed Nov 22 12:02:35 2017 -0700

----------------------------------------------------------------------
 src/master/master.cpp | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/8ea9245e/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 7417b5d..df8f88c 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -6270,8 +6270,11 @@ void Master::__registerSlave(
   message.mutable_connection()->CopyFrom(connection);
   send(slave->pid, message);
 
+  // Note that we convert to `Resources` for output as it's faster than
+  // logging raw protobuf data. Conversion is safe, as resources have
+  // already passed validation.
   LOG(INFO) << "Registered agent " << *slave
-            << " with " << slave->info.resources();
+            << " with " << Resources(slave->info.resources());
 
   slaves.registering.erase(pid);
 }
@@ -6864,8 +6867,11 @@ void Master::__reregisterSlave(
   message.mutable_connection()->CopyFrom(connection);
   send(slave->pid, message);
 
+  // Note that we convert to `Resources` for output as it's faster than
+  // logging raw protobuf data. Conversion is safe, as resources have
+  // already passed validation.
   LOG(INFO) << "Re-registered agent " << *slave
-            << " with " << slave->info.resources();
+            << " with " << Resources(slave->info.resources());
 
   // Determine which frameworks on the slave to shutdown, if any. This
   // happens in two cases:
@@ -9600,8 +9606,11 @@ void Master::removeTask(Task* task)
   CHECK_NOTNULL(slave);
 
   if (!isRemovable(task->state())) {
+    // Note that we convert to `Resources` for output as it's faster than
+    // logging raw protobuf data. Conversion is safe, as resources have
+    // already passed validation.
     LOG(WARNING) << "Removing task " << task->task_id()
-                 << " with resources " << task->resources()
+                 << " with resources " << Resources(task->resources())
                  << " of framework " << task->framework_id()
                  << " on agent " << *slave
                  << " in non-removable state " << task->state();
@@ -9614,8 +9623,11 @@ void Master::removeTask(Task* task)
         task->resources(),
         None());
   } else {
+    // Note that we convert to `Resources` for output as it's faster than
+    // logging raw protobuf data. Conversion is safe, as resources have
+    // already passed validation.
     LOG(INFO) << "Removing task " << task->task_id()
-              << " with resources " << task->resources()
+              << " with resources " << Resources(task->resources())
               << " of framework " << task->framework_id()
               << " on agent " << *slave;
   }
@@ -10790,8 +10802,11 @@ void Slave::addTask(Task* task)
     master->subscribers.send(protobuf::master::event::createTaskAdded(*task));
   }
 
+  // Note that we convert to `Resources` for output as it's faster than
+  // logging raw protobuf data. Conversion is safe, as resources have
+  // already passed validation.
   LOG(INFO) << "Adding task " << taskId
-            << " with resources " << task->resources()
+            << " with resources " << Resources(task->resources())
             << " on agent " << *this;
 }