From: NAKAMURA Takumi Date: Thu, 15 Oct 2015 15:37:13 +0000 (+0000) Subject: Lit: Rework r249161; Move RLIMIT_NPROC to main.py. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=8b7528888dfbb0e10eb364c756c1eeb48a0da589;ds=sidebyside Lit: Rework r249161; Move RLIMIT_NPROC to main.py. The message "raised the process limit..." prevented the progress bar. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250420 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/utils/lit/lit/main.py b/utils/lit/lit/main.py index 630cb54f96d..45ec86d1c3f 100755 --- a/utils/lit/lit/main.py +++ b/utils/lit/lit/main.py @@ -344,6 +344,28 @@ def main(builtinParameters = {}): # Don't create more threads than tests. opts.numThreads = min(len(run.tests), opts.numThreads) + # Because some tests use threads internally, and at least on Linux each + # of these threads counts toward the current process limit, try to + # raise the (soft) process limit so that tests don't fail due to + # resource exhaustion. + try: + cpus = lit.util.detectCPUs() + desired_limit = opts.numThreads * cpus * 2 # the 2 is a safety factor + + # Import the resource module here inside this try block because it + # will likely fail on Windows. + import resource + + max_procs_soft, max_procs_hard = resource.getrlimit(resource.RLIMIT_NPROC) + desired_limit = min(desired_limit, max_procs_hard) + + if max_procs_soft < desired_limit: + resource.setrlimit(resource.RLIMIT_NPROC, (desired_limit, max_procs_hard)) + litConfig.note('raised the process limit from %d to %d' % \ + (max_procs_soft, desired_limit)) + except: + pass + extra = '' if len(run.tests) != numTotalTests: extra = ' of %d' % numTotalTests diff --git a/utils/lit/lit/run.py b/utils/lit/lit/run.py index 4817dd6d1d7..27c414d6dd6 100644 --- a/utils/lit/lit/run.py +++ b/utils/lit/lit/run.py @@ -228,28 +228,6 @@ class Run(object): canceled_flag = LockedValue(0) consumer = ThreadResultsConsumer(display) - # Because some tests use threads internally, and at least on Linux each - # of these threads counts toward the current process limit, try to - # raise the (soft) process limit so that tests don't fail due to - # resource exhaustion. - try: - cpus = lit.util.detectCPUs() - desired_limit = jobs * cpus * 2 # the 2 is a safety factor - - # Import the resource module here inside this try block because it - # will likely fail on Windows. - import resource - - max_procs_soft, max_procs_hard = resource.getrlimit(resource.RLIMIT_NPROC) - desired_limit = min(desired_limit, max_procs_hard) - - if max_procs_soft < desired_limit: - resource.setrlimit(resource.RLIMIT_NPROC, (desired_limit, max_procs_hard)) - self.lit_config.note('raised the process limit from %d to %d' % \ - (max_procs_soft, desired_limit)) - except: - pass - # Create the test provider. provider = TestProvider(self.tests, jobs, queue_impl, canceled_flag)