diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2013-11-27 16:38:29 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-12-10 11:16:12 +0000 |
commit | f8120984f459d193ce5ffa243137baf0e38d223e (patch) | |
tree | 1fd895eb893c332c726e14d7a25869df15a944fe | |
parent | ea307bbcff38fdc93aab438156ed60704e06d27a (diff) | |
download | poky-f8120984f459d193ce5ffa243137baf0e38d223e.tar.gz |
bitbake: toaster: update build stats reading
In the processes of removing local system accesses
from toaster UI, we remove the build stats
code that was moved to toaster.bbclass, and
adapt the database writing code to read the data
from BuildStatsList event sent by the toaster.bbclass
[YOCTO #5604]
(Bitbake rev: 4930ff5b471761c2a8d16c1935cdab9cf141d2d8)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | bitbake/lib/bb/ui/buildinfohelper.py | 64 | ||||
-rw-r--r-- | bitbake/lib/bb/ui/toasterui.py | 2 |
2 files changed, 21 insertions, 45 deletions
diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py index b2e21ef2a6..fef849d9a0 100644 --- a/bitbake/lib/bb/ui/buildinfohelper.py +++ b/bitbake/lib/bb/ui/buildinfohelper.py | |||
@@ -319,23 +319,16 @@ class BuildInfoHelper(object): | |||
319 | assert False | 319 | assert False |
320 | return None | 320 | return None |
321 | 321 | ||
322 | def _get_recipe_information_from_build_event(self, event): | 322 | def _get_recipe_information_from_taskfile(self, taskfile): |
323 | 323 | ||
324 | layer_version_obj = self._get_layer_version_for_path(re.split(':', event.taskfile)[-1]) | 324 | layer_version_obj = self._get_layer_version_for_path(re.split(':', taskfile)[-1]) |
325 | 325 | ||
326 | recipe_info = {} | 326 | recipe_info = {} |
327 | recipe_info['layer_version'] = layer_version_obj | 327 | recipe_info['layer_version'] = layer_version_obj |
328 | recipe_info['file_path'] = re.split(':', event.taskfile)[-1] | 328 | recipe_info['file_path'] = re.split(':', taskfile)[-1] |
329 | 329 | ||
330 | return recipe_info | 330 | return recipe_info |
331 | 331 | ||
332 | def _get_task_build_stats(self, task_object): | ||
333 | bs_path = self._get_path_information(task_object) | ||
334 | for bp in bs_path: # TODO: split for each target | ||
335 | task_build_stats = self._get_build_stats_from_file(bp, task_object.task_name) | ||
336 | |||
337 | return task_build_stats | ||
338 | |||
339 | def _get_path_information(self, task_object): | 332 | def _get_path_information(self, task_object): |
340 | build_stats_format = "{tmpdir}/buildstats/{target}-{machine}/{buildname}/{package}/" | 333 | build_stats_format = "{tmpdir}/buildstats/{target}-{machine}/{buildname}/{package}/" |
341 | build_stats_path = [] | 334 | build_stats_path = [] |
@@ -356,36 +349,6 @@ class BuildInfoHelper(object): | |||
356 | 349 | ||
357 | return build_stats_path | 350 | return build_stats_path |
358 | 351 | ||
359 | def _get_build_stats_from_file(self, bs_path, task_name): | ||
360 | |||
361 | task_bs_filename = str(bs_path) + str(task_name) | ||
362 | task_bs = open(task_bs_filename, 'r') | ||
363 | |||
364 | cpu_usage = 0 | ||
365 | disk_io = 0 | ||
366 | startio = '' | ||
367 | endio = '' | ||
368 | |||
369 | for line in task_bs.readlines(): | ||
370 | if line.startswith('CPU usage: '): | ||
371 | cpu_usage = line[11:] | ||
372 | elif line.startswith('EndTimeIO: '): | ||
373 | endio = line[11:] | ||
374 | elif line.startswith('StartTimeIO: '): | ||
375 | startio = line[13:] | ||
376 | |||
377 | task_bs.close() | ||
378 | |||
379 | if startio and endio: | ||
380 | disk_io = int(endio.strip('\n ')) - int(startio.strip('\n ')) | ||
381 | |||
382 | if cpu_usage: | ||
383 | cpu_usage = float(cpu_usage.strip('% \n')) | ||
384 | |||
385 | task_build_stats = {'cpu_usage': cpu_usage, 'disk_io': disk_io} | ||
386 | |||
387 | return task_build_stats | ||
388 | |||
389 | def _remove_redundant(self, string): | 352 | def _remove_redundant(self, string): |
390 | ret = [] | 353 | ret = [] |
391 | for i in string.split(): | 354 | for i in string.split(): |
@@ -435,7 +398,7 @@ class BuildInfoHelper(object): | |||
435 | def store_started_task(self, event): | 398 | def store_started_task(self, event): |
436 | identifier = event.taskfile + event.taskname | 399 | identifier = event.taskfile + event.taskname |
437 | 400 | ||
438 | recipe_information = self._get_recipe_information_from_build_event(event) | 401 | recipe_information = self._get_recipe_information_from_taskfile(event.taskfile) |
439 | recipe = self.orm_wrapper.get_update_recipe_object(recipe_information) | 402 | recipe = self.orm_wrapper.get_update_recipe_object(recipe_information) |
440 | 403 | ||
441 | task_information = self._get_task_information(event, recipe) | 404 | task_information = self._get_task_information(event, recipe) |
@@ -458,9 +421,23 @@ class BuildInfoHelper(object): | |||
458 | 421 | ||
459 | self.internal_state[identifier] = {'start_time': datetime.datetime.now()} | 422 | self.internal_state[identifier] = {'start_time': datetime.datetime.now()} |
460 | 423 | ||
424 | |||
425 | def store_tasks_stats(self, event): | ||
426 | for (taskfile, taskname, taskstats) in event.data: | ||
427 | recipe_information = self._get_recipe_information_from_taskfile(taskfile) | ||
428 | recipe = self.orm_wrapper.get_update_recipe_object(recipe_information) | ||
429 | |||
430 | task_information = {} | ||
431 | task_information['build'] = self.internal_state['build'] | ||
432 | task_information['recipe'] = recipe | ||
433 | task_information['task_name'] = taskname | ||
434 | task_information['cpu_usage'] = taskstats['cpu_usage'] | ||
435 | task_information['disk_io'] = taskstats['disk_io'] | ||
436 | task_obj = self.orm_wrapper.get_update_task_object(task_information) | ||
437 | |||
461 | def update_and_store_task(self, event): | 438 | def update_and_store_task(self, event): |
462 | identifier = event.taskfile + event.taskname | 439 | identifier = event.taskfile + event.taskname |
463 | recipe_information = self._get_recipe_information_from_build_event(event) | 440 | recipe_information = self._get_recipe_information_from_taskfile(event.taskfile) |
464 | recipe = self.orm_wrapper.get_update_recipe_object(recipe_information) | 441 | recipe = self.orm_wrapper.get_update_recipe_object(recipe_information) |
465 | task_information = self._get_task_information(event,recipe) | 442 | task_information = self._get_task_information(event,recipe) |
466 | try: | 443 | try: |
@@ -483,9 +460,6 @@ class BuildInfoHelper(object): | |||
483 | 460 | ||
484 | if isinstance(event, (bb.runqueue.runQueueTaskCompleted, bb.runqueue.sceneQueueTaskCompleted)): | 461 | if isinstance(event, (bb.runqueue.runQueueTaskCompleted, bb.runqueue.sceneQueueTaskCompleted)): |
485 | task_information['outcome'] = Task.OUTCOME_SUCCESS | 462 | task_information['outcome'] = Task.OUTCOME_SUCCESS |
486 | task_build_stats = self._get_task_build_stats(self.orm_wrapper.get_update_task_object(task_information)) | ||
487 | task_information['cpu_usage'] = task_build_stats['cpu_usage'] | ||
488 | task_information['disk_io'] = task_build_stats['disk_io'] | ||
489 | del self.internal_state[identifier] | 463 | del self.internal_state[identifier] |
490 | 464 | ||
491 | if isinstance(event, (bb.runqueue.runQueueTaskFailed, bb.runqueue.sceneQueueTaskFailed)): | 465 | if isinstance(event, (bb.runqueue.runQueueTaskFailed, bb.runqueue.sceneQueueTaskFailed)): |
diff --git a/bitbake/lib/bb/ui/toasterui.py b/bitbake/lib/bb/ui/toasterui.py index 50493e7b0d..318fc28adb 100644 --- a/bitbake/lib/bb/ui/toasterui.py +++ b/bitbake/lib/bb/ui/toasterui.py | |||
@@ -238,6 +238,8 @@ def main(server, eventHandler, params ): | |||
238 | buildinfohelper.store_build_package_information(event) | 238 | buildinfohelper.store_build_package_information(event) |
239 | if event.type == "LayerInfo": | 239 | if event.type == "LayerInfo": |
240 | buildinfohelper.store_layer_info(event) | 240 | buildinfohelper.store_layer_info(event) |
241 | if event.type == "BuildStatsList": | ||
242 | buildinfohelper.store_tasks_stats(event) | ||
241 | continue | 243 | continue |
242 | 244 | ||
243 | # ignore | 245 | # ignore |