You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2017/08/01 21:03:02 UTC
[04/16] mesos git commit: Added 'process::workers'.
Added 'process::workers'.
Review: https://reviews.apache.org/r/61066
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/7952332e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/7952332e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/7952332e
Branch: refs/heads/master
Commit: 7952332ee32c4a964766f8b51d69495da82efd82
Parents: c70a564
Author: Benjamin Hindman <be...@gmail.com>
Authored: Sun Jul 23 18:22:27 2017 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Tue Aug 1 14:01:51 2017 -0700
----------------------------------------------------------------------
3rdparty/libprocess/include/process/process.hpp | 8 ++++++++
3rdparty/libprocess/src/process.cpp | 12 ++++++++++++
3rdparty/libprocess/src/tests/benchmarks.cpp | 4 ++--
3 files changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/7952332e/3rdparty/libprocess/include/process/process.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/process.hpp b/3rdparty/libprocess/include/process/process.hpp
index 42cd931..252423d 100644
--- a/3rdparty/libprocess/include/process/process.hpp
+++ b/3rdparty/libprocess/include/process/process.hpp
@@ -547,6 +547,14 @@ PID<Logging> logging();
/**
+ * Returns the number of worker threads the library has created. A
+ * worker thread is a thread that runs a process (i.e., calls
+ * `ProcessBase::serve`).
+ */
+long workers();
+
+
+/**
* Spawn a new process.
*
* @param process Process to be spawned.
http://git-wip-us.apache.org/repos/asf/mesos/blob/7952332e/3rdparty/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp
index 59068d5..8bb9d40 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -575,6 +575,11 @@ public:
}
}
+ long workers() const
+ {
+ return threads.size() - 1; // Less 1 for event loop thread.
+ }
+
private:
// Delegate process name to receive root HTTP requests.
const Option<string> delegate;
@@ -1440,6 +1445,13 @@ PID<Logging> logging()
}
+long workers()
+{
+ process::initialize();
+ return process_manager->workers();
+}
+
+
HttpProxy::HttpProxy(const Socket& _socket)
: ProcessBase(ID::generate("__http__")),
socket(_socket) {}
http://git-wip-us.apache.org/repos/asf/mesos/blob/7952332e/3rdparty/libprocess/src/tests/benchmarks.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/benchmarks.cpp b/3rdparty/libprocess/src/tests/benchmarks.cpp
index 694a842..245ff77 100644
--- a/3rdparty/libprocess/src/tests/benchmarks.cpp
+++ b/3rdparty/libprocess/src/tests/benchmarks.cpp
@@ -436,7 +436,7 @@ TEST(ProcessTest, Process_BENCHMARK_ThroughputPerformance)
long repeatFactor = 500L;
long defaultRepeat = 30000L * repeatFactor;
- const size_t numberOfClients = 4;
+ const long numberOfClients = process::workers();
CountDownLatch latch(numberOfClients - 1);
@@ -447,7 +447,7 @@ TEST(ProcessTest, Process_BENCHMARK_ThroughputPerformance)
vector<Owned<Destination>> destinations;
vector<Owned<Client>> clients;
- for (size_t i = 0; i < numberOfClients; i++) {
+ for (long _ = 0; _ < numberOfClients; _++) {
Owned<Destination> destination(new Destination());
spawn(*destination);