Mercurial > piecrust2
comparison piecrust/baking/baker.py @ 421:4a43d7015b75
bake: Improve performance timers reports.
Add timers per-worker, and separate bake and pipeline workers.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 20 Jun 2015 23:27:39 -0700 |
parents | 0e9a94b7fdfa |
children | afeebdd9f767 |
comparison
equal
deleted
inserted
replaced
420:f1b759c188b0 | 421:4a43d7015b75 |
---|---|
105 # All done with the workers. | 105 # All done with the workers. |
106 self._terminateWorkerPool(pool) | 106 self._terminateWorkerPool(pool) |
107 | 107 |
108 # Get the timing information from the workers. | 108 # Get the timing information from the workers. |
109 record.current.timers = {} | 109 record.current.timers = {} |
110 for _ in range(len(pool.workers)): | 110 for i in range(len(pool.workers)): |
111 try: | 111 try: |
112 timers = pool.results.get(True, 0.1) | 112 timers = pool.results.get(True, 0.1) |
113 except queue.Empty: | 113 except queue.Empty: |
114 logger.error("Didn't get timing information from all workers.") | 114 logger.error("Didn't get timing information from all workers.") |
115 break | 115 break |
116 | 116 |
117 worker_name = 'BakeWorker_%d' % i | |
118 record.current.timers[worker_name] = {} | |
117 for name, val in timers['data'].items(): | 119 for name, val in timers['data'].items(): |
118 main_val = record.current.timers.setdefault(name, 0) | 120 main_val = record.current.timers.setdefault(name, 0) |
119 record.current.timers[name] = main_val + val | 121 record.current.timers[name] = main_val + val |
122 record.current.timers[worker_name][name] = val | |
120 | 123 |
121 # Delete files from the output. | 124 # Delete files from the output. |
122 self._handleDeletetions(record) | 125 self._handleDeletetions(record) |
123 | 126 |
124 # Backup previous records. | 127 # Backup previous records. |
547 ctx = BakeWorkerContext( | 550 ctx = BakeWorkerContext( |
548 self.app.root_dir, self.out_dir, | 551 self.app.root_dir, self.out_dir, |
549 pool.queue, pool.results, pool.abort_event, | 552 pool.queue, pool.results, pool.abort_event, |
550 force=self.force, debug=self.app.debug) | 553 force=self.force, debug=self.app.debug) |
551 w = multiprocessing.Process( | 554 w = multiprocessing.Process( |
552 name='Worker_%d' % i, | 555 name='BakeWorker_%d' % i, |
553 target=worker_func, args=(i, ctx)) | 556 target=worker_func, args=(i, ctx)) |
554 w.start() | 557 w.start() |
555 pool.workers.append(w) | 558 pool.workers.append(w) |
556 return pool | 559 return pool |
557 | 560 |