OLD | NEW |
1 # Copyright 2012 the V8 project authors. All rights reserved. | 1 # Copyright 2012 the V8 project authors. All rights reserved. |
2 # Redistribution and use in source and binary forms, with or without | 2 # Redistribution and use in source and binary forms, with or without |
3 # modification, are permitted provided that the following conditions are | 3 # modification, are permitted provided that the following conditions are |
4 # met: | 4 # met: |
5 # | 5 # |
6 # * Redistributions of source code must retain the above copyright | 6 # * Redistributions of source code must retain the above copyright |
7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
8 # * Redistributions in binary form must reproduce the above | 8 # * Redistributions in binary form must reproduce the above |
9 # copyright notice, this list of conditions and the following | 9 # copyright notice, this list of conditions and the following |
10 # disclaimer in the documentation and/or other materials provided | 10 # disclaimer in the documentation and/or other materials provided |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 data, test_map = packet.Pack(self.binaries) | 180 data, test_map = packet.Pack(self.binaries) |
181 compression.Send(data, sock) | 181 compression.Send(data, sock) |
182 compression.Send(constants.END_OF_STREAM, sock) | 182 compression.Send(constants.END_OF_STREAM, sock) |
183 rec = compression.Receiver(sock) | 183 rec = compression.Receiver(sock) |
184 while not rec.IsDone() and not self.terminate: | 184 while not rec.IsDone() and not self.terminate: |
185 data_list = rec.Current() | 185 data_list = rec.Current() |
186 for data in data_list: | 186 for data in data_list: |
187 test_id = data[0] | 187 test_id = data[0] |
188 if test_id < 0: | 188 if test_id < 0: |
189 # The peer is reporting an error. | 189 # The peer is reporting an error. |
190 print("Peer %s reports error: %s" % (peer.address, data[1])) | 190 with self.lock: |
191 rec.Advance() | 191 print("\nPeer %s reports error: %s" % (peer.address, data[1])) |
192 continue | 192 continue |
193 test = test_map.pop(test_id) | 193 test = test_map.pop(test_id) |
194 test.MergeResult(data) | 194 test.MergeResult(data) |
195 try: | 195 try: |
196 self.perfdata.UpdatePerfData(test) | 196 self.perfdata.UpdatePerfData(test) |
197 except Exception, e: | 197 except Exception, e: |
198 print("UpdatePerfData exception: %s" % e) | 198 print("UpdatePerfData exception: %s" % e) |
199 pass # Just keep working. | 199 pass # Just keep working. |
200 with self.lock: | 200 with self.lock: |
201 perf_key = self.perfdata.GetKey(test) | 201 perf_key = self.perfdata.GetKey(test) |
202 compression.Send( | 202 compression.Send( |
203 [constants.INFORM_DURATION, perf_key, test.duration, | 203 [constants.INFORM_DURATION, perf_key, test.duration, |
204 self.context.arch, self.context.mode], | 204 self.context.arch, self.context.mode], |
205 self.local_socket) | 205 self.local_socket) |
206 self.indicator.AboutToRun(test) | 206 self.indicator.AboutToRun(test) |
207 if test.suite.HasUnexpectedOutput(test): | 207 if test.suite.HasUnexpectedOutput(test): |
208 self.failed.append(test) | 208 self.failed.append(test) |
209 if test.output.HasCrashed(): | 209 if test.output.HasCrashed(): |
210 self.crashed += 1 | 210 self.crashed += 1 |
211 else: | 211 else: |
212 self.succeeded += 1 | 212 self.succeeded += 1 |
213 self.remaining -= 1 | 213 self.remaining -= 1 |
214 self.indicator.HasRun(test) | 214 self.indicator.HasRun(test) |
215 rec.Advance() | 215 rec.Advance() |
216 peer.runtime = time.time() - start_time | 216 peer.runtime = time.time() - start_time |
217 except Exception: | 217 except KeyboardInterrupt: |
| 218 sock.close() |
| 219 raise |
| 220 except Exception, e: |
| 221 print("Got exception: %s" % e) |
218 pass # Fall back to local execution. | 222 pass # Fall back to local execution. |
219 else: | 223 else: |
220 compression.Send([constants.UNRESPONSIVE_PEER, peer.address], | 224 compression.Send([constants.UNRESPONSIVE_PEER, peer.address], |
221 self.local_socket) | 225 self.local_socket) |
222 sock.close() | 226 sock.close() |
223 if len(test_map) > 0: | 227 if len(test_map) > 0: |
224 # Some tests have not received any results. Run them locally. | 228 # Some tests have not received any results. Run them locally. |
225 print("No results for %d tests, running them locally." % len(test_map)) | 229 print("\nNo results for %d tests, running them locally." % len(test_map)) |
226 self._EnqueueLocally(test_map) | 230 self._EnqueueLocally(test_map) |
227 | 231 |
228 def _EnqueueLocally(self, test_map): | 232 def _EnqueueLocally(self, test_map): |
229 with self.tests_lock: | 233 with self.tests_lock: |
230 for test in test_map: | 234 for test in test_map: |
231 self.tests.append(test_map[test]) | 235 self.tests.append(test_map[test]) |
232 | 236 |
233 def _AnalyzePeerRuntimes(self): | 237 def _AnalyzePeerRuntimes(self): |
234 total_runtime = 0.0 | 238 total_runtime = 0.0 |
235 total_work = 0.0 | 239 total_work = 0.0 |
236 for p in self.peers: | 240 for p in self.peers: |
237 if p.runtime is None: | 241 if p.runtime is None: |
238 return | 242 return |
239 total_runtime += p.runtime | 243 total_runtime += p.runtime |
240 total_work += p.assigned_work | 244 total_work += p.assigned_work |
241 for p in self.peers: | 245 for p in self.peers: |
242 p.assigned_work /= total_work | 246 p.assigned_work /= total_work |
243 p.runtime /= total_runtime | 247 p.runtime /= total_runtime |
244 perf_correction = p.assigned_work / p.runtime | 248 perf_correction = p.assigned_work / p.runtime |
245 old_perf = p.relative_performance | 249 old_perf = p.relative_performance |
246 p.relative_performance = (old_perf + perf_correction) / 2.0 | 250 p.relative_performance = (old_perf + perf_correction) / 2.0 |
247 compression.Send([constants.UPDATE_PERF, p.address, | 251 compression.Send([constants.UPDATE_PERF, p.address, |
248 p.relative_performance], | 252 p.relative_performance], |
249 self.local_socket) | 253 self.local_socket) |
OLD | NEW |