Changeset 78502 in webkit
- Timestamp:
- Feb 14, 2011 1:48:25 PM (13 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r78420 r78502 1 2011-02-14 Dirk Pranke <dpranke@chromium.org> 2 3 Reviewed by Tony Chang. 4 5 update the NRWT multiprocessing code to spawn multiple workers 6 instead of just using one. 7 8 https://bugs.webkit.org/show_bug.cgi?id=54071 9 10 * Scripts/webkitpy/layout_tests/layout_package/test_runner2.py: 11 1 12 2011-02-12 Chang Shu <cshu@webkit.org> 2 13 -
trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/test_runner2.py
r78398 r78502 35 35 36 36 import logging 37 import time 37 38 39 from webkitpy.tool import grammar 38 40 39 41 from webkitpy.layout_tests.layout_package import manager_worker_broker … … 44 46 45 47 48 class _WorkerState(object): 49 """A class for the TestRunner/manager to use to track the current state 50 of the workers.""" 51 def __init__(self, number, worker_connection): 52 self.worker_connection = worker_connection 53 self.number = number 54 self.done = False 55 56 def __repr__(self): 57 return "_WorkerState(" + str(self.__dict__) + ")" 58 59 46 60 class TestRunner2(test_runner.TestRunner): 47 61 def __init__(self, port, options, printer): … … 50 64 self._group_stats = {} 51 65 self._current_result_summary = None 52 self._done = False 66 67 # This maps worker names to the state we are tracking for each of them. 68 self._worker_states = {} 53 69 54 70 def is_done(self): 55 return self._done 71 worker_states = self._worker_states.values() 72 return worker_states and all(self._worker_is_done(worker_state) for worker_state in worker_states) 73 74 def _worker_is_done(self, worker_state): 75 # FIXME: check if the worker is wedged. 76 return worker_state.done 56 77 57 78 def name(self): … … 73 94 """ 74 95 self._current_result_summary = result_summary 96 self._all_results = [] 97 self._worker_states = {} 75 98 76 # FIXME: shard properly.99 num_workers = self._num_workers() 77 100 78 # FIXME: should shard_tests return a list of objects rather than tuples? 79 test_lists = self._shard_tests(file_list, False) 101 self._printer.print_update('Sharding tests ...') 102 test_lists = self._shard_tests(file_list, 103 num_workers > 1 and not self._options.experimental_fully_parallel) 104 _log.debug("Using %d shards" % len(test_lists)) 80 105 81 manager_connection = manager_worker_broker.get(self._port, self._options, self, worker.Worker) 106 manager_connection = manager_worker_broker.get(self._port, self._options, 107 self, worker.Worker) 82 108 83 # FIXME: start all of the workers. 84 manager_connection.start_worker(0) 109 self._printer.print_update('Starting %s ...' % 110 grammar.pluralize('worker', num_workers)) 111 for worker_number in xrange(num_workers): 112 worker_connection = manager_connection.start_worker(worker_number) 113 worker_state = _WorkerState(worker_number, worker_connection) 114 self._worker_states[worker_connection.name] = worker_state 115 116 # FIXME: If we start workers up too quickly, DumpRenderTree appears 117 # to thrash on something and time out its first few tests. Until 118 # we can figure out what's going on, sleep a bit in between 119 # workers. 120 time.sleep(0.1) 85 121 86 122 for test_list in test_lists: 87 123 manager_connection.post_message('test_list', test_list[0], test_list[1]) 88 124 89 manager_connection.post_message('stop') 125 # We post one 'stop' message for each worker. Because the stop message 126 # are sent after all of the tests, and because each worker will stop 127 # reading messsages after receiving a stop, we can be sure each 128 # worker will get a stop message and hence they will all shut down. 129 for i in xrange(num_workers): 130 manager_connection.post_message('stop') 90 131 91 132 keyboard_interrupted = False 92 133 interrupted = False 93 134 if not self._options.dry_run: 94 while not self._check_if_done(): 135 while not self.is_done(): 136 # We loop with a timeout in order to be able to detect wedged threads. 95 137 manager_connection.run_message_loop(delay_secs=1.0) 96 138 139 # FIXME: handle exceptions, interrupts. 140 97 141 # FIXME: implement stats. 142 98 143 thread_timings = [] 99 144 … … 102 147 self._group_stats, self._all_results) 103 148 104 def _check_if_done(self): 105 """Returns true iff all the workers have either completed or wedged.""" 106 # FIXME: implement to check for wedged workers. 107 return self._done 108 109 def handle_started_test(self, src, test_info, hang_timeout): 149 def handle_started_test(self, source, test_info, hang_timeout): 110 150 # FIXME: implement 111 151 pass 112 152 113 def handle_done(self, src): 114 # FIXME: implement properly to handle multiple workers. 115 self._done = True 116 pass 153 def handle_done(self, source): 154 worker_state = self._worker_states[source] 155 worker_state.done = True 117 156 118 def handle_exception(self, s rc, exception_info):157 def handle_exception(self, source, exception_info): 119 158 raise exception_info 120 159 121 def handle_finished_list(self, s rc, list_name, num_tests, elapsed_time):160 def handle_finished_list(self, source, list_name, num_tests, elapsed_time): 122 161 # FIXME: update stats 123 162 pass 124 163 125 def handle_finished_test(self, s rc, result, elapsed_time):164 def handle_finished_test(self, source, result, elapsed_time): 126 165 self._update_summary_with_result(self._current_result_summary, result) 127 166
Note: See TracChangeset
for help on using the changeset viewer.