[PATCH] D13389: [lit] Raise the default soft process limit when possible

hfinkel@anl.gov via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 2 10:32:36 PDT 2015


hfinkel removed rL LLVM as the repository for this revision.
hfinkel updated this revision to Diff 36376.
hfinkel added a comment.

Don't print the note if it did not work.


http://reviews.llvm.org/D13389

Files:
  utils/lit/lit/run.py

Index: utils/lit/lit/run.py
===================================================================
--- utils/lit/lit/run.py
+++ utils/lit/lit/run.py
@@ -228,6 +228,28 @@
             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)
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13389.36376.patch
Type: text/x-patch
Size: 1346 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151002/3b818ab0/attachment.bin>


More information about the llvm-commits mailing list