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/07/25 21:16:14 UTC

[1/3] mesos git commit: Updated metrics add / remove to avoid double lookups.

Repository: mesos
Updated Branches:
  refs/heads/master 8f378c6b7 -> 2685f1488


Updated metrics add / remove to avoid double lookups.

When adding / removing metrics, we were performing double lookups
on the metrics map. Removing these provides a slight performance
improvement.

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


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

Branch: refs/heads/master
Commit: 2685f148896667f9a77e5e3d2f01d92ec8963609
Parents: 54a8443
Author: Benjamin Mahler <bm...@apache.org>
Authored: Wed Jul 11 15:49:15 2018 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Wed Jul 25 14:13:51 2018 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/src/metrics/metrics.cpp | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2685f148/3rdparty/libprocess/src/metrics/metrics.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/metrics/metrics.cpp b/3rdparty/libprocess/src/metrics/metrics.cpp
index e2fdbc7..ba1962f 100644
--- a/3rdparty/libprocess/src/metrics/metrics.cpp
+++ b/3rdparty/libprocess/src/metrics/metrics.cpp
@@ -120,23 +120,24 @@ string MetricsProcess::help()
 
 Future<Nothing> MetricsProcess::add(Owned<Metric> metric)
 {
-  if (metrics.count(metric->name()) > 0) {
+  bool inserted = metrics.emplace(metric->name(), metric).second;
+
+  if (!inserted) {
     return Failure("Metric '" + metric->name() + "' was already added");
   }
 
-  metrics[metric->name()] = metric;
   return Nothing();
 }
 
 
 Future<Nothing> MetricsProcess::remove(const string& name)
 {
-  if (metrics.count(name) == 0) {
+  size_t erased = metrics.erase(name);
+
+  if (erased == 0) {
     return Failure("Metric '" + name + "' not found");
   }
 
-  metrics.erase(name);
-
   return Nothing();
 }
 


[2/3] mesos git commit: Installed google's signal handler for libprocess benchmarks.

Posted by bm...@apache.org.
Installed google's signal handler for libprocess benchmarks.

This will provide a stack trace if the benchmarks crash, the
approach here was followed from the libprocess test main.cpp.

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


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

Branch: refs/heads/master
Commit: 54a8443d76b2b43140e412f1d2bf73fee856885f
Parents: f3f75e8
Author: Benjamin Mahler <bm...@apache.org>
Authored: Wed Jul 11 15:47:04 2018 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Wed Jul 25 14:13:51 2018 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/src/tests/benchmarks.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/54a8443d/3rdparty/libprocess/src/tests/benchmarks.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/benchmarks.cpp b/3rdparty/libprocess/src/tests/benchmarks.cpp
index e3a604d..0b94aaf 100644
--- a/3rdparty/libprocess/src/tests/benchmarks.cpp
+++ b/3rdparty/libprocess/src/tests/benchmarks.cpp
@@ -71,6 +71,18 @@ int main(int argc, char** argv)
   // Initialize Google Mock/Test.
   testing::InitGoogleMock(&argc, argv);
 
+  // NOTE: Windows does not support signal semantics required for these
+  // handlers to be useful.
+#ifndef __WINDOWS__
+  // Install GLOG's signal handler.
+  google::InstallFailureSignalHandler();
+
+  // We reset the GLOG's signal handler for SIGTERM because
+  // 'SubprocessTest.Status' sends SIGTERM to a subprocess which
+  // results in a stack trace otherwise.
+  os::signals::reset(SIGTERM);
+#endif // __WINDOWS__
+
   // Add the libprocess test event listeners.
   ::testing::TestEventListeners& listeners =
     ::testing::UnitTest::GetInstance()->listeners();


[3/3] mesos git commit: Added a metrics scalability benchmark in libprocess.

Posted by bm...@apache.org.
Added a metrics scalability benchmark in libprocess.

This initial benchmark focuses on adding a large number of counters
and measuring how long the add/remove and snapshot takes.

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


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

Branch: refs/heads/master
Commit: f3f75e8797cb9ef2c9b0c69fd7e289f9c4e8617b
Parents: 8f378c6
Author: Benjamin Mahler <bm...@apache.org>
Authored: Tue Jul 10 13:42:36 2018 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Wed Jul 25 14:13:51 2018 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/src/tests/benchmarks.cpp | 71 +++++++++++++++++++++++
 1 file changed, 71 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/f3f75e87/3rdparty/libprocess/src/tests/benchmarks.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/benchmarks.cpp b/3rdparty/libprocess/src/tests/benchmarks.cpp
index aed90ed..e3a604d 100644
--- a/3rdparty/libprocess/src/tests/benchmarks.cpp
+++ b/3rdparty/libprocess/src/tests/benchmarks.cpp
@@ -34,6 +34,9 @@
 #include <process/process.hpp>
 #include <process/protobuf.hpp>
 
+#include <process/metrics/counter.hpp>
+#include <process/metrics/metrics.hpp>
+
 #include <stout/duration.hpp>
 #include <stout/gtest.hpp>
 #include <stout/hashset.hpp>
@@ -44,6 +47,7 @@
 #include "mpsc_linked_queue.hpp"
 
 namespace http = process::http;
+namespace metrics = process::metrics;
 
 using process::CountDownLatch;
 using process::Future;
@@ -60,6 +64,8 @@ using std::ostringstream;
 using std::string;
 using std::vector;
 
+using testing::WithParamInterface;
+
 int main(int argc, char** argv)
 {
   // Initialize Google Mock/Test.
@@ -754,3 +760,68 @@ TEST(ProcessTest, Process_BENCHMARK_MpscLinkedQueue)
   cout << "Estimated total throughput: "
        << std::fixed << throughput << " op/s" << endl;
 }
+
+
+class Metrics_BENCHMARK_Test : public ::testing::Test,
+                               public WithParamInterface<size_t>{};
+
+
+// Parameterized by the number of metrics.
+INSTANTIATE_TEST_CASE_P(
+    MetricsCount,
+    Metrics_BENCHMARK_Test,
+    ::testing::Values(1u, 100u, 1000u, 10000u, 100000u));
+
+
+// Tests the performance of metrics fetching when there
+// are a large number of metrics.
+TEST_P(Metrics_BENCHMARK_Test, Scalability)
+{
+  size_t metrics_count = GetParam();
+
+  vector<metrics::Counter> counters;
+  counters.reserve(metrics_count);
+
+  for (size_t i = 0; i < metrics_count; ++i) {
+    counters.push_back(
+        metrics::Counter("metrics/keys/can/be/somewhat/long/"
+                         "so/we/use/a/fairly/long/key/here/"
+                         "to/test/a/more/pathological/case/" +
+                         stringify(i)));
+  }
+
+  Stopwatch watch;
+  watch.start();
+  for (size_t i = 0; i < metrics_count; ++i) {
+    metrics::add(counters[i]).get();
+  }
+  watch.stop();
+
+  std::cout << "Added " << metrics_count << " counters in "
+            << watch.elapsed() << std::endl;
+
+  watch.start();
+  metrics::snapshot(None()).get();
+  watch.stop();
+
+  std::cout << "Snapshot of " << metrics_count << " counters in "
+              << watch.elapsed() << std::endl;
+
+  UPID upid("metrics", process::address());
+
+  watch.start();
+  http::get(upid, "snapshot").get();
+  watch.stop();
+
+  std::cout << "HTTP /snapshot of " << metrics_count << " counters in "
+              << watch.elapsed() << std::endl;
+
+  watch.start();
+  for (size_t i = 0; i < metrics_count; ++i) {
+    metrics::remove(counters[i]).get();
+  }
+  watch.stop();
+
+  std::cout << "Removed " << metrics_count << " counters in "
+            << watch.elapsed() << std::endl;
+}