Skip to content
Snippets Groups Projects
Commit 94e5ddec authored by ctiller's avatar ctiller Committed by Nicolas Noble
Browse files

Only run one make at a time.

If openssl has not been built, running parallel make processes causes some problems.
	Change on 2015/01/09 by ctiller <ctiller@google.com>
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=83617340
parent a5cf7bd7
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ import tempfile ...@@ -8,7 +8,7 @@ import tempfile
import time import time
_MAX_JOBS = 16 * multiprocessing.cpu_count() _DEFAULT_MAX_JOBS = 16 * multiprocessing.cpu_count()
def shuffle_iteratable(it): def shuffle_iteratable(it):
...@@ -81,15 +81,16 @@ class Job(object): ...@@ -81,15 +81,16 @@ class Job(object):
class Jobset(object): class Jobset(object):
"""Manages one run of jobs.""" """Manages one run of jobs."""
def __init__(self, check_cancelled): def __init__(self, check_cancelled, maxjobs):
self._running = set() self._running = set()
self._check_cancelled = check_cancelled self._check_cancelled = check_cancelled
self._cancelled = False self._cancelled = False
self._failures = 0 self._failures = 0
self._maxjobs = maxjobs
def start(self, cmdline): def start(self, cmdline):
"""Start a job. Return True on success, False on failure.""" """Start a job. Return True on success, False on failure."""
while len(self._running) >= _MAX_JOBS: while len(self._running) >= self._maxjobs:
if self.cancelled(): return False if self.cancelled(): return False
self.reap() self.reap()
if self.cancelled(): return False if self.cancelled(): return False
...@@ -130,10 +131,10 @@ def _never_cancelled(): ...@@ -130,10 +131,10 @@ def _never_cancelled():
return False return False
def run(cmdlines, check_cancelled=_never_cancelled): def run(cmdlines, check_cancelled=_never_cancelled, maxjobs=None):
js = Jobset(check_cancelled) js = Jobset(check_cancelled,
maxjobs if maxjobs is not None else _DEFAULT_MAX_JOBS)
for cmdline in shuffle_iteratable(cmdlines): for cmdline in shuffle_iteratable(cmdlines):
if not js.start(cmdline): if not js.start(cmdline):
break break
return js.finish() return js.finish()
...@@ -43,10 +43,10 @@ def _build_and_run(check_cancelled): ...@@ -43,10 +43,10 @@ def _build_and_run(check_cancelled):
# build latest, sharing cpu between the various makes # build latest, sharing cpu between the various makes
if not jobset.run( if not jobset.run(
(['make', (['make',
'-j', '%d' % max(multiprocessing.cpu_count() / len(configs), 1), '-j', '%d' % (multiprocessing.cpu_count() + 1),
'buildtests_c', 'buildtests_c',
'CONFIG=%s' % cfg] 'CONFIG=%s' % cfg]
for cfg in configs), check_cancelled): for cfg in configs), check_cancelled, maxjobs=1):
sys.exit(1) sys.exit(1)
# run all the tests # run all the tests
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment