diff options
author | Filipe Cabecinhas <me@filcab.net> | 2016-03-17 18:27:33 +0000 |
---|---|---|
committer | Filipe Cabecinhas <me@filcab.net> | 2016-03-17 18:27:33 +0000 |
commit | e2a5365d555b8a395ed2c76a2236047b6b8f02f9 (patch) | |
tree | 763bbcc7ace269fc4cdb9928ab11ce5c7a08bcd9 /utils | |
parent | 562564f42bdb43dc5ae7291712e268a3ed588f64 (diff) | |
download | llvm-e2a5365d555b8a395ed2c76a2236047b6b8f02f9.tar.gz |
[lit] Enqueue tests on a separate thread to not hit limits on parallel queues
Summary:
The multiprocessing.Queue.put() call can hang if we try queueing all the
tests before starting to take them out of the queue.
The current implementation hangs if tests exceed 2^^15, on Mac OS X.
This might happen with a ninja check-all if one has a bunch of llvm
projects.
Reviewers: delcypher, bkramer
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D17609
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263731 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/lit/lit/run.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/utils/lit/lit/run.py b/utils/lit/lit/run.py index 27c414d6dd65..bbf644ef7dbe 100644 --- a/utils/lit/lit/run.py +++ b/utils/lit/lit/run.py @@ -44,11 +44,13 @@ class LockedValue(object): value = property(_get_value, _set_value) class TestProvider(object): - def __init__(self, tests, num_jobs, queue_impl, canceled_flag): + def __init__(self, queue_impl, canceled_flag): self.canceled_flag = canceled_flag # Create a shared queue to provide the test indices. self.queue = queue_impl() + + def queue_tests(self, tests, num_jobs): for i in range(len(tests)): self.queue.put(i) for i in range(num_jobs): @@ -229,7 +231,15 @@ class Run(object): consumer = ThreadResultsConsumer(display) # Create the test provider. - provider = TestProvider(self.tests, jobs, queue_impl, canceled_flag) + provider = TestProvider(queue_impl, canceled_flag) + + # Queue the tests outside the main thread because we can't guarantee + # that we can put() all the tests without blocking: + # https://docs.python.org/2/library/multiprocessing.html + # e.g: On Mac OS X, we will hang if we put 2^15 elements in the queue + # without taking any out. + queuer = task_impl(target=provider.queue_tests, args=(self.tests, jobs)) + queuer.start() # Install a console-control signal handler on Windows. if win32api is not None: @@ -252,6 +262,8 @@ class Run(object): # Otherwise, execute the tests in parallel self._execute_tests_in_parallel(task_impl, provider, consumer, jobs) + queuer.join() + # Cancel the timeout handler. if max_time is not None: timeout_timer.cancel() |