summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/cooker.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-12 23:55:48 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-15 08:35:07 +0100
commitaf04a52bf7d7ae94c187e85028a80dee6d7853f0 (patch)
treed0c65de172d7ded2e1ba28f09c271da97e10cbe9 /bitbake/lib/bb/cooker.py
parent29b4fb17966bfaec74b41cce533725c04ec1078f (diff)
downloadpoky-af04a52bf7d7ae94c187e85028a80dee6d7853f0.tar.gz
bitbake: taskdata/runqueue: Rewrite without use of ID indirection
I'm not sure what possesed me when I wrote this code originally but its indirection of everyting to use numeric IDs and position dependent lists is horrific. Given the way python internals work, its completely and utterly pointless from performance perspective. It also makes the code hard to understand and debug since any numeric ID has to be translated into something human readable. The hard part is that the IDs are infectous and spread from taskdata into runqueue and even partly into cooker for the dependency graph processing. The only real way to deal with this is to convert everything to use a more sane data structure. This patch: * Uses "<fn>:<taskname>" as the ID for tasks rather than a number * Changes to dict() based structures rather than position dependent lists * Drops the build name, runtime name and filename ID indexes On the most part there shouldn't be user visible changes. Sadly we did leak datastructures to the setscene verify function which has to be rewritten. To handle this, the variable name used to specifiy the version changes from BB_SETSCENE_VERIFY_FUNCTION to BB_SETSCENE_VERIFY_FUNCTION2 allowing multiple versions of bitbake to work with suitably written metadata. Anyone with custom schedulers may also need to change them. I believe the benefits in code readability and easier debugging far outweigh those issues though. It also means we have a saner codebase to add multiconfig support on top of. During development, I did have some of the original code coexisting with the new data stores to allow comparision of the data and check it was working correcty, particuarly for taskdata. I have also compared task-depends.dot files before and after the change. There should be no functionality changes in this patch, its purely a data structure change and that is visible in the patch. (Bitbake rev: 2c88afb60da54e58f555411a7bd7b006b0c29306) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/cooker.py')
-rw-r--r--bitbake/lib/bb/cooker.py72
1 files changed, 29 insertions, 43 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index ce818f3e59..907565401d 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -623,9 +623,7 @@ class BBCooker:
623 623
624 taskdata, runlist, pkgs_to_build = self.buildTaskData(pkgs_to_build, None, self.configuration.abort, allowincomplete=True) 624 taskdata, runlist, pkgs_to_build = self.buildTaskData(pkgs_to_build, None, self.configuration.abort, allowincomplete=True)
625 625
626 targetid = taskdata.getbuild_id(pkgs_to_build[0]) 626 fn = taskdata.build_targets[pkgs_to_build[0]][0]
627 fnid = taskdata.build_targets[targetid][0]
628 fn = taskdata.fn_index[fnid]
629 else: 627 else:
630 envdata = self.data 628 envdata = self.data
631 629
@@ -714,7 +712,7 @@ class BBCooker:
714 712
715 713
716 def buildDependTree(self, rq, taskdata): 714 def buildDependTree(self, rq, taskdata):
717 seen_fnids = [] 715 seen_fns = []
718 depend_tree = {} 716 depend_tree = {}
719 depend_tree["depends"] = {} 717 depend_tree["depends"] = {}
720 depend_tree["tdepends"] = {} 718 depend_tree["tdepends"] = {}
@@ -732,10 +730,9 @@ class BBCooker:
732 version = "%s:%s-%s" % self.recipecache.pkg_pepvpr[fn] 730 version = "%s:%s-%s" % self.recipecache.pkg_pepvpr[fn]
733 depend_tree['providermap'][name] = (pn, version) 731 depend_tree['providermap'][name] = (pn, version)
734 732
735 for task in range(len(rq.rqdata.runq_fnid)): 733 for tid in rq.rqdata.runtaskentries:
736 taskname = rq.rqdata.runq_task[task] 734 taskname = bb.runqueue.taskname_from_tid(tid)
737 fnid = rq.rqdata.runq_fnid[task] 735 fn = bb.runqueue.fn_from_tid(tid)
738 fn = taskdata.fn_index[fnid]
739 pn = self.recipecache.pkg_fn[fn] 736 pn = self.recipecache.pkg_fn[fn]
740 version = "%s:%s-%s" % self.recipecache.pkg_pepvpr[fn] 737 version = "%s:%s-%s" % self.recipecache.pkg_pepvpr[fn]
741 if pn not in depend_tree["pn"]: 738 if pn not in depend_tree["pn"]:
@@ -756,24 +753,24 @@ class BBCooker:
756 depend_tree["pn"][pn][ei] = vars(self.recipecache)[ei][fn] 753 depend_tree["pn"][pn][ei] = vars(self.recipecache)[ei][fn]
757 754
758 755
759 for dep in rq.rqdata.runq_depends[task]: 756 for dep in rq.rqdata.runtaskentries[tid].depends:
760 depfn = taskdata.fn_index[rq.rqdata.runq_fnid[dep]] 757 depfn = bb.runqueue.fn_from_tid(dep)
761 deppn = self.recipecache.pkg_fn[depfn] 758 deppn = self.recipecache.pkg_fn[depfn]
762 dotname = "%s.%s" % (pn, rq.rqdata.runq_task[task]) 759 dotname = "%s.%s" % (pn, bb.runqueue.taskname_from_tid(dep))
763 if not dotname in depend_tree["tdepends"]: 760 if not dotname in depend_tree["tdepends"]:
764 depend_tree["tdepends"][dotname] = [] 761 depend_tree["tdepends"][dotname] = []
765 depend_tree["tdepends"][dotname].append("%s.%s" % (deppn, rq.rqdata.runq_task[dep])) 762 depend_tree["tdepends"][dotname].append("%s.%s" % (deppn, bb.runqueue.taskname_from_tid(dep)))
766 if fnid not in seen_fnids: 763 if fn not in seen_fns:
767 seen_fnids.append(fnid) 764 seen_fns.append(fn)
768 packages = [] 765 packages = []
769 766
770 depend_tree["depends"][pn] = [] 767 depend_tree["depends"][pn] = []
771 for dep in taskdata.depids[fnid]: 768 for dep in taskdata.depids[fn]:
772 depend_tree["depends"][pn].append(taskdata.build_names_index[dep]) 769 depend_tree["depends"][pn].append(dep)
773 770
774 depend_tree["rdepends-pn"][pn] = [] 771 depend_tree["rdepends-pn"][pn] = []
775 for rdep in taskdata.rdepids[fnid]: 772 for rdep in taskdata.rdepids[fn]:
776 depend_tree["rdepends-pn"][pn].append(taskdata.run_names_index[rdep]) 773 depend_tree["rdepends-pn"][pn].append(rdep)
777 774
778 rdepends = self.recipecache.rundeps[fn] 775 rdepends = self.recipecache.rundeps[fn]
779 for package in rdepends: 776 for package in rdepends:
@@ -805,12 +802,8 @@ class BBCooker:
805 Create a dependency tree of pkgs_to_build, returning the data. 802 Create a dependency tree of pkgs_to_build, returning the data.
806 """ 803 """
807 _, taskdata = self.prepareTreeData(pkgs_to_build, task) 804 _, taskdata = self.prepareTreeData(pkgs_to_build, task)
808 tasks_fnid = []
809 if len(taskdata.tasks_name) != 0:
810 for task in range(len(taskdata.tasks_name)):
811 tasks_fnid.append(taskdata.tasks_fnid[task])
812 805
813 seen_fnids = [] 806 seen_fns = []
814 depend_tree = {} 807 depend_tree = {}
815 depend_tree["depends"] = {} 808 depend_tree["depends"] = {}
816 depend_tree["pn"] = {} 809 depend_tree["pn"] = {}
@@ -825,9 +818,8 @@ class BBCooker:
825 cachefields = getattr(cache_class, 'cachefields', []) 818 cachefields = getattr(cache_class, 'cachefields', [])
826 extra_info = extra_info + cachefields 819 extra_info = extra_info + cachefields
827 820
828 for task in range(len(tasks_fnid)): 821 for tid in taskdata.taskentries:
829 fnid = tasks_fnid[task] 822 fn = bb.runqueue.fn_from_tid(tid)
830 fn = taskdata.fn_index[fnid]
831 pn = self.recipecache.pkg_fn[fn] 823 pn = self.recipecache.pkg_fn[fn]
832 824
833 if pn not in depend_tree["pn"]: 825 if pn not in depend_tree["pn"]:
@@ -843,33 +835,27 @@ class BBCooker:
843 for ei in extra_info: 835 for ei in extra_info:
844 depend_tree["pn"][pn][ei] = vars(self.recipecache)[ei][fn] 836 depend_tree["pn"][pn][ei] = vars(self.recipecache)[ei][fn]
845 837
846 if fnid not in seen_fnids: 838 if fn not in seen_fns:
847 seen_fnids.append(fnid) 839 seen_fns.append(fn)
848 840
849 depend_tree["depends"][pn] = [] 841 depend_tree["depends"][pn] = []
850 for dep in taskdata.depids[fnid]: 842 for item in taskdata.depids[fn]:
851 item = taskdata.build_names_index[dep]
852 pn_provider = "" 843 pn_provider = ""
853 targetid = taskdata.getbuild_id(item) 844 if dep in taskdata.build_targets and taskdata.build_targets[dep]:
854 if targetid in taskdata.build_targets and taskdata.build_targets[targetid]: 845 fn_provider = taskdata.build_targets[dep][0]
855 id = taskdata.build_targets[targetid][0]
856 fn_provider = taskdata.fn_index[id]
857 pn_provider = self.recipecache.pkg_fn[fn_provider] 846 pn_provider = self.recipecache.pkg_fn[fn_provider]
858 else: 847 else:
859 pn_provider = item 848 pn_provider = item
860 depend_tree["depends"][pn].append(pn_provider) 849 depend_tree["depends"][pn].append(pn_provider)
861 850
862 depend_tree["rdepends-pn"][pn] = [] 851 depend_tree["rdepends-pn"][pn] = []
863 for rdep in taskdata.rdepids[fnid]: 852 for rdep in taskdata.rdepids[fn]:
864 item = taskdata.run_names_index[rdep]
865 pn_rprovider = "" 853 pn_rprovider = ""
866 targetid = taskdata.getrun_id(item) 854 if rdep in taskdata.run_targets and taskdata.run_targets[rdep]:
867 if targetid in taskdata.run_targets and taskdata.run_targets[targetid]: 855 fn_rprovider = taskdata.run_targets[rdep][0]
868 id = taskdata.run_targets[targetid][0]
869 fn_rprovider = taskdata.fn_index[id]
870 pn_rprovider = self.recipecache.pkg_fn[fn_rprovider] 856 pn_rprovider = self.recipecache.pkg_fn[fn_rprovider]
871 else: 857 else:
872 pn_rprovider = item 858 pn_rprovider = rdep
873 depend_tree["rdepends-pn"][pn].append(pn_rprovider) 859 depend_tree["rdepends-pn"][pn].append(pn_rprovider)
874 860
875 depend_tree["rdepends-pkg"].update(rdepends) 861 depend_tree["rdepends-pkg"].update(rdepends)
@@ -1350,7 +1336,7 @@ class BBCooker:
1350 return False 1336 return False
1351 1337
1352 if not retval: 1338 if not retval:
1353 bb.event.fire(bb.event.BuildCompleted(len(rq.rqdata.runq_fnid), buildname, item, failures, interrupted), self.expanded_data) 1339 bb.event.fire(bb.event.BuildCompleted(len(rq.rqdata.runtaskentries), buildname, item, failures, interrupted), self.expanded_data)
1354 self.command.finishAsyncCommand(msg) 1340 self.command.finishAsyncCommand(msg)
1355 return False 1341 return False
1356 if retval is True: 1342 if retval is True:
@@ -1386,7 +1372,7 @@ class BBCooker:
1386 return False 1372 return False
1387 1373
1388 if not retval: 1374 if not retval:
1389 bb.event.fire(bb.event.BuildCompleted(len(rq.rqdata.runq_fnid), buildname, targets, failures, interrupted), self.data) 1375 bb.event.fire(bb.event.BuildCompleted(len(rq.rqdata.runtaskentries), buildname, targets, failures, interrupted), self.data)
1390 self.command.finishAsyncCommand(msg) 1376 self.command.finishAsyncCommand(msg)
1391 return False 1377 return False
1392 if retval is True: 1378 if retval is True: