Skip to content
This repository has been archived by the owner on Jan 27, 2019. It is now read-only.

Commit

Permalink
oelite/oven.py: record and store detailed task timings
Browse files Browse the repository at this point in the history
All pre- and post-funcs run synchronously in the main oe process. Some
of these tend to be rather time-consuming, so it would be better if they
could be made into tasks of their own, or run as part of the main task
function, or just optimized to run faster. Otherwise, the oven risks
being underused for a long time (for example, some do_install script
finishes, and we go on to execute the associated postfuncs, which may
take > 30 seconds to complete - meanwhile, some do_compile task has
finished, but there's no way we'll notice before we're done with those
postfuncs).

Knowing which tasks' pre- and postfuncs take a long time is useful for
finding recipes (or maybe whole classes) that are worth optimizing.
  • Loading branch information
Rasmus Villemoes committed Nov 10, 2016
1 parent d35485c commit 2364682
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/oelite/oven.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self, baker, capacity=None):
self.capacity = capacity
self.baker = baker
self.starttime = dict()
self.completed_tasks = []
self.failed_tasks = []
self.total = baker.runq.number_of_tasks_to_build()
self.count = 0
Expand Down Expand Up @@ -99,12 +100,14 @@ def wait_task(self, poll, task):
if result is None:
return None
delta = self.remove(task)
task.task_time = delta

task.recipe.remaining_tasks -= 1
if result:
info("%s finished - %s s" % (task, delta))
task.build_done(self.baker.runq.get_task_buildhash(task))
self.baker.runq.mark_done(task)
self.completed_tasks.append(task)
else:
err("%s failed - %s s" % (task, delta))
self.failed_tasks.append(task)
Expand Down Expand Up @@ -163,3 +166,8 @@ def write_profiling_data(self):
out.write("%-16s %7.1fs / %5d = %7.3fs [%s]\n" %
(name, stats.sum, stats.count, stats.mean, quarts))

with oelite.profiling.profile_output("task_times.txt") as f:
for task in self.completed_tasks:
f.write("%s\t%.3f\t%.3f\t%.3f\t%.3f\n" %
(task, task.task_time, task.prefunc_time, task.func_time, task.postfunc_time))

6 changes: 6 additions & 0 deletions lib/oelite/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,15 @@ def _start(self):
self.apply_context()

try:
prefunc_start = oelite.util.now()
for prefunc in self.get_prefuncs():
print "running prefunc", prefunc
self.do_cleandirs(prefunc)
wd = self.do_dirs(prefunc)
if not prefunc.run(wd or self.cwd):
return False
self.func_start = oelite.util.now()
self.prefunc_time = self.func_start - prefunc_start
try:
# start() doesn't return a value - but it may throw an
# exception. For, I think, mostly historical reasons,
Expand Down Expand Up @@ -290,13 +293,16 @@ def wait(self, poll=False):
# failed. In either case, we shouldn't run the
# postfuncs. Otherwise, we should run them.
if self.result:
func_end = oelite.util.now()
self.func_time = func_end - self.func_start
for postfunc in self.get_postfuncs():
print "running postfunc", postfunc
self.do_cleandirs(postfunc)
wd = self.do_dirs(postfunc)
if not postfunc.run(wd or self.cwd):
self.result = False
break
self.postfunc_time = oelite.util.now() - func_end
finally:
self.restore_context()

Expand Down

0 comments on commit 2364682

Please sign in to comment.