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 2016/07/19 02:29:20 UTC

mesos git commit: Replaced an os::sleep with Clock::settle in allocator benchmark.

Repository: mesos
Updated Branches:
  refs/heads/master 4d97171c1 -> 2e5201889


Replaced an os::sleep with Clock::settle in allocator benchmark.

Currently, in HierarchicalAllocator_BENCHMARK_Test.AddAndUpdateSlave,
we are using 'sleep' to check if the operations are processed, this
is not accurate, we should use 'Clock::settle' instead.

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


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

Branch: refs/heads/master
Commit: 2e5201889ca30f5afda069d88d972024dbbaae3f
Parents: 4d97171
Author: Guangya Liu <gy...@gmail.com>
Authored: Mon Jul 18 19:27:06 2016 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Mon Jul 18 19:27:06 2016 -0700

----------------------------------------------------------------------
 src/tests/hierarchical_allocator_tests.cpp | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2e520188/src/tests/hierarchical_allocator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/hierarchical_allocator_tests.cpp b/src/tests/hierarchical_allocator_tests.cpp
index 65c3fe6..3ddce7a 100644
--- a/src/tests/hierarchical_allocator_tests.cpp
+++ b/src/tests/hierarchical_allocator_tests.cpp
@@ -3313,14 +3313,12 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, AddAndUpdateSlave)
 
   Clock::pause();
 
-  // Number of allocations. This is used to determine
-  // the termination condition.
-  atomic<size_t> finished(0);
+  atomic<size_t> offerCallbacks(0);
 
-  auto offerCallback = [&finished](
+  auto offerCallback = [&offerCallbacks](
       const FrameworkID& frameworkId,
       const hashmap<SlaveID, Resources>& resources) {
-    finished++;
+    offerCallbacks++;
   };
 
   initialize(master::Flags(), offerCallback);
@@ -3332,6 +3330,9 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, AddAndUpdateSlave)
     allocator->addFramework(framework.id(), framework, {});
   }
 
+  // Wait for all the `addFramework` operations to be processed.
+  Clock::settle();
+
   watch.stop();
 
   cout << "Added " << frameworkCount << " frameworks"
@@ -3359,12 +3360,12 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, AddAndUpdateSlave)
   }
 
   // Wait for all the `addSlave` operations to be processed.
-  while (finished.load() != slaveCount) {
-    os::sleep(Milliseconds(10));
-  }
+  Clock::settle();
 
   watch.stop();
 
+  ASSERT_EQ(slaveCount, offerCallbacks.load());
+
   cout << "Added " << slaveCount << " agents"
        << " in " << watch.elapsed() << endl;
 
@@ -3379,12 +3380,12 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, AddAndUpdateSlave)
   }
 
   // Wait for all the `updateSlave` operations to be processed.
-  while (finished.load() != 2 * slaveCount) {
-    os::sleep(Milliseconds(10));
-  }
+  Clock::settle();
 
   watch.stop();
 
+  ASSERT_EQ(slaveCount * 2, offerCallbacks.load());
+
   cout << "Updated " << slaveCount << " agents in " << watch.elapsed() << endl;
 }