diff options
author | Nicolas Despres <nicolas.despres@gmail.com> | 2012-04-05 13:44:36 (GMT) |
---|---|---|
committer | Nicolas Despres <nicolas.despres@gmail.com> | 2012-04-19 13:29:26 (GMT) |
commit | b50f7d1f30991998564f62aa717862efb7555044 (patch) | |
tree | 95161e6f0fd8c201ac5bc30c0fb5bd4796ba90ce /src/build.cc | |
parent | 5da8529d9c0e5fa2ad586c0608b5a936286cf9a2 (diff) | |
download | Ninja-b50f7d1f30991998564f62aa717862efb7555044.zip Ninja-b50f7d1f30991998564f62aa717862efb7555044.tar.gz Ninja-b50f7d1f30991998564f62aa717862efb7555044.tar.bz2 |
Add -l N option to limit the load average.
This is similar to GNU make -l/--load-average option. It limits the number
of job started if the load average exceed the given value. It can be very
useful when running ninja on a continuous integration server where we want
to use parallelism as much as possible without overloading the server.
Diffstat (limited to 'src/build.cc')
-rw-r--r-- | src/build.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/build.cc b/src/build.cc index 6063cec..a269e50 100644 --- a/src/build.cc +++ b/src/build.cc @@ -452,7 +452,9 @@ void RealCommandRunner::Abort() { } bool RealCommandRunner::CanRunMore() { - return ((int)subprocs_.running_.size()) < config_.parallelism; + return ((int)subprocs_.running_.size()) < config_.parallelism + && ((subprocs_.running_.size() == 0 || config_.max_load_average <= 0.0f) + || GetLoadAverage() < config_.max_load_average); } bool RealCommandRunner::StartCommand(Edge* edge) { |