You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by id...@apache.org on 2014/09/26 19:21:52 UTC
git commit: Dynamically change poll interval in the reaper.
Repository: mesos
Updated Branches:
refs/heads/master 8e5ab0e30 -> 343b150ed
Dynamically change poll interval in the reaper.
If pid count <= 50 then use 100 ms (<= 0.5% core usage), if count
>= 500 use 1000 ms (<= 1% core usage at 500 pids), else interpolate.
Review: https://reviews.apache.org/r/25947
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/343b150e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/343b150e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/343b150e
Branch: refs/heads/master
Commit: 343b150ed4a6649a7b0389f5da3974ed77c90924
Parents: 8e5ab0e
Author: Ian Downes <id...@twitter.com>
Authored: Mon Sep 22 17:44:07 2014 -0700
Committer: Ian Downes <id...@twitter.com>
Committed: Fri Sep 26 10:13:26 2014 -0700
----------------------------------------------------------------------
3rdparty/libprocess/src/reap.cpp | 43 +++++++++++++++++++++++++++++++++--
1 file changed, 41 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/343b150e/3rdparty/libprocess/src/reap.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/reap.cpp b/3rdparty/libprocess/src/reap.cpp
index b350ee1..ac14a86 100644
--- a/3rdparty/libprocess/src/reap.cpp
+++ b/3rdparty/libprocess/src/reap.cpp
@@ -23,7 +23,29 @@ namespace process {
// TODO(bmahler): This can be optimized to use a thread per pid, where
// each thread makes a blocking call to waitpid. This eliminates the
-// unfortunate 1 second reap delay.
+// unfortunate poll delay.
+//
+// Simple bounded linear model for computing the poll interval.
+// Values were chosen such that at (50 pids, 100 ms) the CPU usage is
+// less than approx. 0.5% of a single core, and at (500 pids, 1000 ms)
+// less than approx. 1.0% of single core. Tested on Linux 3.10 with
+// Intel Xeon E5620 and OSX 10.9 with Intel i7 4980HQ.
+//
+// 1000ms _____
+// /
+// (interval) /
+// /
+// 100ms -----/
+// 50 500
+//
+// (# pids)
+//
+const size_t LOW_PID_COUNT = 50;
+const Duration LOW_INTERVAL = Milliseconds(100);
+
+const size_t HIGH_PID_COUNT = 500;
+const Duration HIGH_INTERVAL = Seconds(1);
+
class ReaperProcess : public Process<ReaperProcess>
{
@@ -68,7 +90,7 @@ protected:
}
}
- delay(Seconds(1), self(), &ReaperProcess::wait); // Reap forever!
+ delay(interval(), self(), &ReaperProcess::wait); // Reap forever!
}
void notify(pid_t pid, Result<int> status)
@@ -86,6 +108,23 @@ protected:
}
private:
+ const Duration interval()
+ {
+ size_t count = promises.size();
+
+ if (count <= LOW_PID_COUNT) {
+ return LOW_INTERVAL;
+ } else if (count >= HIGH_PID_COUNT) {
+ return HIGH_INTERVAL;
+ }
+
+ // Linear interpolation between LOW_INTERVAL and HIGH_INTERVAL.
+ double fraction =
+ ((double) (count - LOW_PID_COUNT) / (HIGH_PID_COUNT - LOW_PID_COUNT));
+
+ return LOW_INTERVAL + (HIGH_INTERVAL - LOW_INTERVAL) * fraction;
+ }
+
multihashmap<pid_t, Owned<Promise<Option<int> > > > promises;
};