[llvm] r375055 - [lit] Do not create semaphores when we do not need them

Julian Lettner via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 16 16:25:47 PDT 2019


Author: yln
Date: Wed Oct 16 16:25:46 2019
New Revision: 375055

URL: http://llvm.org/viewvc/llvm-project?rev=375055&view=rev
Log:
[lit] Do not create semaphores when we do not need them

Parallelism groups and semaphores are only required for parallel
execution.

Modified:
    llvm/trunk/utils/lit/lit/run.py

Modified: llvm/trunk/utils/lit/lit/run.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/run.py?rev=375055&r1=375054&r2=375055&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/run.py (original)
+++ llvm/trunk/utils/lit/lit/run.py Wed Oct 16 16:25:46 2019
@@ -19,11 +19,6 @@ class Run(object):
     def __init__(self, lit_config, tests):
         self.lit_config = lit_config
         self.tests = tests
-        # Set up semaphores to limit parallelism of certain classes of tests.
-        self.parallelism_semaphores = {
-                k : NopSemaphore() if v is None else
-                    multiprocessing.BoundedSemaphore(v)
-                for k, v in lit_config.parallelism_groups.items()}
 
     def execute_tests(self, progress_callback, workers, max_time):
         """
@@ -76,14 +71,18 @@ class Run(object):
         if max_time:
             deadline = time.time() + max_time
 
+        semaphores = {
+            k: NopSemaphore() if v is None else
+            multiprocessing.BoundedSemaphore(v) for k, v in
+            self.lit_config.parallelism_groups.items()}
+
         # Start a process pool. Copy over the data shared between all test runs.
         # FIXME: Find a way to capture the worker process stderr. If the user
         # interrupts the workers before we make it into our task callback, they
         # will each raise a KeyboardInterrupt exception and print to stderr at
         # the same time.
         pool = multiprocessing.Pool(workers, lit.worker.initializer,
-                                    (self.lit_config,
-                                     self.parallelism_semaphores))
+                                    (self.lit_config, semaphores))
 
         # Install a console-control signal handler on Windows.
         if lit.util.win32api is not None:




More information about the llvm-commits mailing list