Don't limit ninja -j on Linux beyond ulimit -n
macOS limits the ninja j value to 1000, because ninja has a limit to the
number of open file descriptors of FD_SETSIZE, which is 1024 on Darwin.
On Linux, the ninja binary distributed on Chromium seems to be compiled
with poll.h support, so that this limitation doesn't exist:
https://github.com/ninja-build/ninja/blob/22b778ca197562d55e64bd07faa3b37b064492a7/src/subprocess-posix.cc#L59
Change-Id: I97848bb99c08fe118dbdaea525da713382373c9d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4866223
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
diff --git a/autoninja.py b/autoninja.py
index a3effe0..08d9b0f 100755
--- a/autoninja.py
+++ b/autoninja.py
@@ -273,12 +273,14 @@
j_value = min(j_value, core_limit)
# On Windows, a -j higher than 1000 doesn't improve build times.
- # On POSIX, ninja is limited to at most FD_SETSIZE (1024) open file
+ # On macOS, ninja is limited to at most FD_SETSIZE (1024) open file
# descriptors.
- j_value = min(j_value, 1000)
+ if sys.platform in ['darwin', 'win32']:
+ j_value = min(j_value, 1000)
+
+ # Use a j value that reliably works with the open file descriptors
+ # limit.
if sys.platform in ['darwin', 'linux']:
- # Use a j value that reliably works with the open file
- # descriptors limit.
j_value = min(j_value, int(fileno_limit * 0.8))
args.append('%d' % j_value)