Mercurial > piecrust2
comparison piecrust/processing/worker.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 | c4b3a7fd2f87 |
children | 5ceb86818dc5 |
comparison
equal
deleted
inserted
replaced
420:f1b759c188b0 | 421:4a43d7015b75 |
---|---|
71 work_start_time = time.perf_counter() | 71 work_start_time = time.perf_counter() |
72 | 72 |
73 # Create the app local to this worker. | 73 # Create the app local to this worker. |
74 app = PieCrust(self.ctx.root_dir, debug=self.ctx.debug) | 74 app = PieCrust(self.ctx.root_dir, debug=self.ctx.debug) |
75 app.env.fs_cache_only_for_main_page = True | 75 app.env.fs_cache_only_for_main_page = True |
76 app.env.registerTimer("Worker_%d" % self.wid) | 76 app.env.registerTimer("PipelineWorker_%d_Total" % self.wid) |
77 app.env.registerTimer("PipelineWorkerInit") | |
77 app.env.registerTimer("JobReceive") | 78 app.env.registerTimer("JobReceive") |
78 app.env.registerTimer('BuildProcessingTree') | 79 app.env.registerTimer('BuildProcessingTree') |
79 app.env.registerTimer('RunProcessingTree') | 80 app.env.registerTimer('RunProcessingTree') |
80 | 81 |
81 processors = app.plugin_loader.getProcessors() | 82 processors = app.plugin_loader.getProcessors() |
100 | 101 |
101 # Sort our processors again in case the pre-process step involved | 102 # Sort our processors again in case the pre-process step involved |
102 # patching the processors with some new ones. | 103 # patching the processors with some new ones. |
103 processors.sort(key=lambda p: p.priority) | 104 processors.sort(key=lambda p: p.priority) |
104 | 105 |
106 app.env.stepTimerSince("PipelineWorkerInit", work_start_time) | |
107 | |
105 aborted_with_exception = None | 108 aborted_with_exception = None |
106 while not self.ctx.abort_event.is_set(): | 109 while not self.ctx.abort_event.is_set(): |
107 try: | 110 try: |
108 with app.env.timerScope('JobReceive'): | 111 with app.env.timerScope('JobReceive'): |
109 job = self.ctx.work_queue.get(True, 0.01) | 112 job = self.ctx.work_queue.get(True, 0.01) |
129 | 132 |
130 # Invoke post-processors. | 133 # Invoke post-processors. |
131 for proc in processors: | 134 for proc in processors: |
132 proc.onPipelineEnd(pipeline_ctx) | 135 proc.onPipelineEnd(pipeline_ctx) |
133 | 136 |
134 app.env.stepTimer("Worker_%d" % self.wid, | 137 app.env.stepTimerSince("PipelineWorker_%d_Total" % self.wid, |
135 time.perf_counter() - work_start_time) | 138 work_start_time) |
136 self.ctx.results.put_nowait({ | 139 self.ctx.results.put_nowait({ |
137 'type': 'timers', 'data': app.env._timers}) | 140 'type': 'timers', 'data': app.env._timers}) |
138 | 141 |
139 def _unsafeRun(self, app, processors, job): | 142 def _unsafeRun(self, app, processors, job): |
140 result = ProcessingWorkerResult(job.path) | 143 result = ProcessingWorkerResult(job.path) |