diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-11-02 09:02:15 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-11-03 10:12:42 +0000 |
commit | 34e4eebc32c4836fc40098e90b17c00f51398967 (patch) | |
tree | 20f3ba43c0341cbed8b454c92d60e0fc326b9d50 /bitbake/lib/bb/ui/buildinfohelper.py | |
parent | 791d6e63be09b361dd3397707a0507399b9a9ce7 (diff) | |
download | poky-34e4eebc32c4836fc40098e90b17c00f51398967.tar.gz |
bitbake: lib/bb: Fix string concatination potential performance issues
Python scales badly when concatinating strings in loops. Most of these
references aren't problematic but at least one (in data.py) is probably
a performance issue as the issue is compounded as strings become large.
The way to handle this in python is to create lists which don't reconstruct
all the objects when appending to them. We may as well fix all the references
since it stops them being copy/pasted into something problematic in the future.
This patch was based on issues highligthted by a report from AWS Codeguru.
(Bitbake rev: d654139a833127b16274dca0ccbbab7e3bb33ed0)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/ui/buildinfohelper.py')
-rw-r--r-- | bitbake/lib/bb/ui/buildinfohelper.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py index 8588849dd4..835e92c299 100644 --- a/bitbake/lib/bb/ui/buildinfohelper.py +++ b/bitbake/lib/bb/ui/buildinfohelper.py | |||
@@ -571,7 +571,7 @@ class ORMWrapper(object): | |||
571 | assert isinstance(build_obj, Build) | 571 | assert isinstance(build_obj, Build) |
572 | assert isinstance(target_obj, Target) | 572 | assert isinstance(target_obj, Target) |
573 | 573 | ||
574 | errormsg = "" | 574 | errormsg = [] |
575 | for p in packagedict: | 575 | for p in packagedict: |
576 | # Search name swtiches round the installed name vs package name | 576 | # Search name swtiches round the installed name vs package name |
577 | # by default installed name == package name | 577 | # by default installed name == package name |
@@ -636,7 +636,7 @@ class ORMWrapper(object): | |||
636 | if packagefile_objects: | 636 | if packagefile_objects: |
637 | Package_File.objects.bulk_create(packagefile_objects) | 637 | Package_File.objects.bulk_create(packagefile_objects) |
638 | except KeyError as e: | 638 | except KeyError as e: |
639 | errormsg += " stpi: Key error, package %s key %s \n" % ( p, e ) | 639 | errormsg.append(" stpi: Key error, package %s key %s \n" % (p, e)) |
640 | 640 | ||
641 | # save disk installed size | 641 | # save disk installed size |
642 | packagedict[p]['object'].installed_size = packagedict[p]['size'] | 642 | packagedict[p]['object'].installed_size = packagedict[p]['size'] |
@@ -678,8 +678,8 @@ class ORMWrapper(object): | |||
678 | else: | 678 | else: |
679 | logger.info("No package dependencies created") | 679 | logger.info("No package dependencies created") |
680 | 680 | ||
681 | if len(errormsg) > 0: | 681 | if errormsg: |
682 | logger.warning("buildinfohelper: target_package_info could not identify recipes: \n%s", errormsg) | 682 | logger.warning("buildinfohelper: target_package_info could not identify recipes: \n%s", "".join(errormsg)) |
683 | 683 | ||
684 | def save_target_image_file_information(self, target_obj, file_name, file_size): | 684 | def save_target_image_file_information(self, target_obj, file_name, file_size): |
685 | Target_Image_File.objects.create(target=target_obj, | 685 | Target_Image_File.objects.create(target=target_obj, |
@@ -1404,7 +1404,7 @@ class BuildInfoHelper(object): | |||
1404 | assert 'pn' in event._depgraph | 1404 | assert 'pn' in event._depgraph |
1405 | assert 'tdepends' in event._depgraph | 1405 | assert 'tdepends' in event._depgraph |
1406 | 1406 | ||
1407 | errormsg = "" | 1407 | errormsg = [] |
1408 | 1408 | ||
1409 | # save layer version priorities | 1409 | # save layer version priorities |
1410 | if 'layer-priorities' in event._depgraph.keys(): | 1410 | if 'layer-priorities' in event._depgraph.keys(): |
@@ -1496,7 +1496,7 @@ class BuildInfoHelper(object): | |||
1496 | elif dep in self.internal_state['recipes']: | 1496 | elif dep in self.internal_state['recipes']: |
1497 | dependency = self.internal_state['recipes'][dep] | 1497 | dependency = self.internal_state['recipes'][dep] |
1498 | else: | 1498 | else: |
1499 | errormsg += " stpd: KeyError saving recipe dependency for %s, %s \n" % (recipe, dep) | 1499 | errormsg.append(" stpd: KeyError saving recipe dependency for %s, %s \n" % (recipe, dep)) |
1500 | continue | 1500 | continue |
1501 | recipe_dep = Recipe_Dependency(recipe=target, | 1501 | recipe_dep = Recipe_Dependency(recipe=target, |
1502 | depends_on=dependency, | 1502 | depends_on=dependency, |
@@ -1537,8 +1537,8 @@ class BuildInfoHelper(object): | |||
1537 | taskdeps_objects.append(Task_Dependency( task = target, depends_on = dep )) | 1537 | taskdeps_objects.append(Task_Dependency( task = target, depends_on = dep )) |
1538 | Task_Dependency.objects.bulk_create(taskdeps_objects) | 1538 | Task_Dependency.objects.bulk_create(taskdeps_objects) |
1539 | 1539 | ||
1540 | if len(errormsg) > 0: | 1540 | if errormsg: |
1541 | logger.warning("buildinfohelper: dependency info not identify recipes: \n%s", errormsg) | 1541 | logger.warning("buildinfohelper: dependency info not identify recipes: \n%s", "".join(errormsg)) |
1542 | 1542 | ||
1543 | 1543 | ||
1544 | def store_build_package_information(self, event): | 1544 | def store_build_package_information(self, event): |