mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bmah...@apache.org
Subject [mesos] 01/02: Avoided double copying of outgoing messages in the master.
Date Fri, 07 Sep 2018 00:24:55 GMT
This is an automated email from the ASF dual-hosted git repository.

bmahler pushed a commit to branch 1.7.x
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 875fe9b61623254ec11665fd8c089ba492260798
Author: Benjamin Mahler <bmahler@apache.org>
AuthorDate: Thu Sep 6 15:31:48 2018 -0700

    Avoided double copying of outgoing messages in the master.
    
    When framework metrics were introduced, there was an evolve + devolve
    conversion occuring in order to map old style messages to the new
    `scheduler::Event::Type`. This results in copying all outgoing
    messages twice.
    
    This patch avoids the copying by adding overloads for the old style
    messages.
    
    Review: https://reviews.apache.org/r/68662
---
 src/master/master.hpp  |   4 +-
 src/master/metrics.cpp | 100 +++++++++++++++++++++++++++++++++++++++++++++++--
 src/master/metrics.hpp |  14 +++++++
 3 files changed, 112 insertions(+), 6 deletions(-)

diff --git a/src/master/master.hpp b/src/master/master.hpp
index 7b11c32..fedc581 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -2533,9 +2533,7 @@ void Framework::send(const Message& message)
                  << " framework " << *this;
   }
 
-  // TODO(gilbert): add a helper to transform `SchedulerDriver` API messages
-  // directly to v0 events.
-  metrics.incrementEvent(devolve(evolve(message)));
+  metrics.incrementEvent(message);
 
   if (http.isSome()) {
     if (!http->send(message)) {
diff --git a/src/master/metrics.cpp b/src/master/metrics.cpp
index 655c75a..56a7eef 100644
--- a/src/master/metrics.cpp
+++ b/src/master/metrics.cpp
@@ -755,10 +755,104 @@ string getFrameworkMetricPrefix(const FrameworkInfo& frameworkInfo)
 
 void FrameworkMetrics::incrementEvent(const scheduler::Event& event)
 {
-  CHECK(event_types.contains(event.type()));
+  ++CHECK_NOTNONE(event_types.get(event.type()));
+  ++events;
+}
+
+
+void FrameworkMetrics::incrementEvent(
+    const FrameworkErrorMessage& message)
+{
+  ++CHECK_NOTNONE(event_types.get(scheduler::Event::ERROR));
+  ++events;
+}
+
+
+void FrameworkMetrics::incrementEvent(
+    const ExitedExecutorMessage& message)
+{
+  ++CHECK_NOTNONE(event_types.get(scheduler::Event::FAILURE));
+  ++events;
+}
+
+
+void FrameworkMetrics::incrementEvent(
+    const LostSlaveMessage& message)
+{
+  ++CHECK_NOTNONE(event_types.get(scheduler::Event::FAILURE));
+  ++events;
+}
+
+
+void FrameworkMetrics::incrementEvent(
+    const InverseOffersMessage& message)
+{
+  ++CHECK_NOTNONE(event_types.get(scheduler::Event::INVERSE_OFFERS));
+  ++events;
+}
+
 
-  event_types.get(event.type()).get()++;
-  events++;
+void FrameworkMetrics::incrementEvent(
+    const ExecutorToFrameworkMessage& message)
+{
+  ++CHECK_NOTNONE(event_types.get(scheduler::Event::MESSAGE));
+  ++events;
+}
+
+
+void FrameworkMetrics::incrementEvent(
+    const ResourceOffersMessage& message)
+{
+  ++CHECK_NOTNONE(event_types.get(scheduler::Event::OFFERS));
+  ++events;
+}
+
+
+void FrameworkMetrics::incrementEvent(
+    const RescindResourceOfferMessage& message)
+{
+  ++CHECK_NOTNONE(event_types.get(scheduler::Event::RESCIND));
+  ++events;
+}
+
+
+void FrameworkMetrics::incrementEvent(
+    const RescindInverseOfferMessage& message)
+{
+  ++CHECK_NOTNONE(event_types.get(scheduler::Event::RESCIND_INVERSE_OFFER));
+  ++events;
+}
+
+
+void FrameworkMetrics::incrementEvent(
+    const FrameworkRegisteredMessage& message)
+{
+  ++CHECK_NOTNONE(event_types.get(scheduler::Event::SUBSCRIBED));
+  ++events;
+}
+
+
+void FrameworkMetrics::incrementEvent(
+    const FrameworkReregisteredMessage& message)
+{
+  ++CHECK_NOTNONE(event_types.get(scheduler::Event::SUBSCRIBED));
+  ++events;
+}
+
+
+void FrameworkMetrics::incrementEvent(
+    const StatusUpdateMessage& message)
+{
+  ++CHECK_NOTNONE(event_types.get(scheduler::Event::UPDATE));
+  ++events;
+}
+
+
+void FrameworkMetrics::incrementEvent(
+    const UpdateOperationStatusMessage& message)
+{
+  ++CHECK_NOTNONE(event_types.get(scheduler::Event::UPDATE_OPERATION_STATUS));
+  ++events;
 }
 
 } // namespace master {
diff --git a/src/master/metrics.hpp b/src/master/metrics.hpp
index df28a48..a805515 100644
--- a/src/master/metrics.hpp
+++ b/src/master/metrics.hpp
@@ -228,6 +228,20 @@ struct FrameworkMetrics
 
   void incrementEvent(const scheduler::Event& event);
 
+  // Overloads to convert unversioned messages into events.
+  void incrementEvent(const FrameworkErrorMessage& message);
+  void incrementEvent(const ExitedExecutorMessage& message);
+  void incrementEvent(const LostSlaveMessage& message);
+  void incrementEvent(const InverseOffersMessage& message);
+  void incrementEvent(const ExecutorToFrameworkMessage& message);
+  void incrementEvent(const ResourceOffersMessage& message);
+  void incrementEvent(const RescindResourceOfferMessage& message);
+  void incrementEvent(const RescindInverseOfferMessage& message);
+  void incrementEvent(const FrameworkRegisteredMessage& message);
+  void incrementEvent(const FrameworkReregisteredMessage& message);
+  void incrementEvent(const StatusUpdateMessage& message);
+  void incrementEvent(const UpdateOperationStatusMessage& message);
+
   void incrementTaskState(const TaskState& state);
   void decrementActiveTaskState(const TaskState& state);
 


Mime
View raw message