From 7eb4e4841f43a5ad3e00ee96c2bc58df5cefd0be Mon Sep 17 00:00:00 2001 From: Henrique Ferreiro Date: Wed, 20 Sep 2023 20:25:20 +0000 Subject: [PATCH] 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 Reviewed-by: Takuto Ikuta Reviewed-by: Dirk Pranke --- autoninja.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/autoninja.py b/autoninja.py index a3effe00a..08d9b0f3e 100755 --- a/autoninja.py +++ b/autoninja.py @@ -273,12 +273,14 @@ def main(args): 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)