Index: scripts/slave/recipe_modules/goma/api.py |
diff --git a/scripts/slave/recipe_modules/goma/api.py b/scripts/slave/recipe_modules/goma/api.py |
index 97c12f3f6e200a5787d3a682631de8b9f410a1b0..bef04fd982d1505c9b3daf0b505843fb8d13b84e 100644 |
--- a/scripts/slave/recipe_modules/goma/api.py |
+++ b/scripts/slave/recipe_modules/goma/api.py |
@@ -14,6 +14,7 @@ class GomaApi(recipe_api.RecipeApi): |
self._goma_ctl_env = {} |
self._cloudtail_pid = None |
+ self._goma_jobs = 50 |
@property |
def service_account_json_path(self): |
@@ -31,6 +32,10 @@ class GomaApi(recipe_api.RecipeApi): |
assert self._goma_dir |
return self.m.path.join(self._goma_dir, 'jsonstatus') |
+ @property |
+ def goma_jobs(self): |
ukai
2016/09/05 05:30:32
better to have docstring?
tikuta
2016/09/05 09:01:55
Done.
|
+ return self._goma_jobs |
+ |
def ensure_goma(self, canary=False): |
with self.m.step.nest('ensure_goma'): |
with self.m.step.context({'infra_step': True}): |
@@ -65,6 +70,26 @@ class GomaApi(recipe_api.RecipeApi): |
{goma_package: ref, |
cloudtail_package: cloudtail_version}) |
+ step_result = self.m.python.inline( |
+ 'get the number of cpus', |
+ """ |
+ import multiprocessing |
+ |
+ try: |
+ jobs = min(200, multiprocessing.cpu_count() * 10) |
+ except NotImplementedError: |
+ jobs = 50 |
+ |
+ print jobs |
+ """, |
+ stdout=self.m.raw_io.output(), |
+ step_test_data=( |
+ lambda: self.m.raw_io.test_api.stream_output('50\n')) |
+ ) |
+ self._goma_jobs = int(step_result.stdout) |
+ if self.m.platform.is_linux: |
ukai
2016/09/05 05:30:32
no need to run python.inline above for this case (
tikuta
2016/09/05 09:01:55
I moved this step into the function to calculate _
|
+ self._goma_jobs = 80 |
+ |
return self._goma_dir |
except self.m.step.StepFailure: |
# TODO(phajdan.jr): make failures fatal after experiment. |