From 1bc3cd228ef445429638ebe22f0c59ed5b396ccf Mon Sep 17 00:00:00 2001 From: Aleksey Khoroshilov Date: Mon, 9 May 2022 19:49:42 +0000 Subject: [PATCH] Add a global core limit support for goma/rbe builds. This is very usable for non Google-sized Goma clusters. We want to use NINJA_CORE_MULTIPLIER logic, but at the same time we don't want to stall our cluster with super-high -j values. Bug: 1323475 Change-Id: I2ed414463b4f397a7bcebe42ea0b996e52006cda Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3632492 Auto-Submit: Aleksey Khoroshilov Reviewed-by: Bruce Dawson Commit-Queue: Bruce Dawson --- autoninja.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/autoninja.py b/autoninja.py index 0e5f5a379..8d3026248 100755 --- a/autoninja.py +++ b/autoninja.py @@ -176,9 +176,11 @@ def main(args): core_multiplier = int( os.environ.get('NINJA_CORE_MULTIPLIER', default_core_multiplier)) - j_value = num_cores * core_multiplier + core_limit = int(os.environ.get('NINJA_CORE_LIMIT', j_value)) + j_value = min(j_value, core_limit) + if sys.platform.startswith('win'): # On windows, j value higher than 1000 does not improve build # performance.