summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/runqueue.py
diff options
context:
space:
mode:
authorBob Foerster <robert@erafx.com>2010-11-20 04:39:22 +0800
committerRichard Purdie <rpurdie@linux.intel.com>2011-01-04 14:46:42 +0000
commitc6328564de8e8cae113ee559d769105f9f4b6003 (patch)
treec557df9ea46a3ed9501e14829be7db0af09239a7 /bitbake/lib/bb/runqueue.py
parente81fc749f34df0b6944849f217840b3a7a027af8 (diff)
downloadpoky-c6328564de8e8cae113ee559d769105f9f4b6003.tar.gz
Prefer xrange over range for small performance gain.
range() allocates an actual list when called. xrange() is just an iterator and creates the next range item on demand. This provides a slight performance increase. In python 3, range will do what xrange does currently, but the upgrade will be handled by the 2to3 tool. (Bitbake rev: 73b40f06444cb877a5960b2aa66abf7dacbd88f0) Signed-off-by: Bob Foerster <robert@erafx.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb/runqueue.py')
-rw-r--r--bitbake/lib/bb/runqueue.py54
1 files changed, 27 insertions, 27 deletions
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py
index 2b81540a14..a80feb9504 100644
--- a/bitbake/lib/bb/runqueue.py
+++ b/bitbake/lib/bb/runqueue.py
@@ -233,7 +233,7 @@ class RunQueueData:
233 return "%s, %s" % (fn, taskname) 233 return "%s, %s" % (fn, taskname)
234 234
235 def get_task_id(self, fnid, taskname): 235 def get_task_id(self, fnid, taskname):
236 for listid in range(len(self.runq_fnid)): 236 for listid in xrange(len(self.runq_fnid)):
237 if self.runq_fnid[listid] == fnid and self.runq_task[listid] == taskname: 237 if self.runq_fnid[listid] == fnid and self.runq_task[listid] == taskname:
238 return listid 238 return listid
239 return None 239 return None
@@ -255,7 +255,7 @@ class RunQueueData:
255 """ 255 """
256 lowest = 0 256 lowest = 0
257 new_chain = [] 257 new_chain = []
258 for entry in range(len(chain)): 258 for entry in xrange(len(chain)):
259 if chain[entry] < chain[lowest]: 259 if chain[entry] < chain[lowest]:
260 lowest = entry 260 lowest = entry
261 new_chain.extend(chain[lowest:]) 261 new_chain.extend(chain[lowest:])
@@ -268,7 +268,7 @@ class RunQueueData:
268 """ 268 """
269 if len(chain1) != len(chain2): 269 if len(chain1) != len(chain2):
270 return False 270 return False
271 for index in range(len(chain1)): 271 for index in xrange(len(chain1)):
272 if chain1[index] != chain2[index]: 272 if chain1[index] != chain2[index]:
273 return False 273 return False
274 return True 274 return True
@@ -339,7 +339,7 @@ class RunQueueData:
339 deps_left = [] 339 deps_left = []
340 task_done = [] 340 task_done = []
341 341
342 for listid in range(numTasks): 342 for listid in xrange(numTasks):
343 task_done.append(False) 343 task_done.append(False)
344 weight.append(0) 344 weight.append(0)
345 deps_left.append(len(self.runq_revdeps[listid])) 345 deps_left.append(len(self.runq_revdeps[listid]))
@@ -363,7 +363,7 @@ class RunQueueData:
363 363
364 # Circular dependency sanity check 364 # Circular dependency sanity check
365 problem_tasks = [] 365 problem_tasks = []
366 for task in range(numTasks): 366 for task in xrange(numTasks):
367 if task_done[task] is False or deps_left[task] != 0: 367 if task_done[task] is False or deps_left[task] != 0:
368 problem_tasks.append(task) 368 problem_tasks.append(task)
369 logger.debug(2, "Task %s (%s) is not buildable\n", task, self.get_user_idstring(task)) 369 logger.debug(2, "Task %s (%s) is not buildable\n", task, self.get_user_idstring(task))
@@ -441,7 +441,7 @@ class RunQueueData:
441 if taskid is not None: 441 if taskid is not None:
442 depends.append(taskid) 442 depends.append(taskid)
443 443
444 for task in range(len(taskData.tasks_name)): 444 for task in xrange(len(taskData.tasks_name)):
445 depends = [] 445 depends = []
446 recrdepends = [] 446 recrdepends = []
447 fnid = taskData.tasks_fnid[task] 447 fnid = taskData.tasks_fnid[task]
@@ -532,7 +532,7 @@ class RunQueueData:
532 # Algorithm is O(tasks) + O(tasks)*O(fnids) 532 # Algorithm is O(tasks) + O(tasks)*O(fnids)
533 # 533 #
534 reccumdepends = {} 534 reccumdepends = {}
535 for task in range(len(self.runq_fnid)): 535 for task in xrange(len(self.runq_fnid)):
536 fnid = self.runq_fnid[task] 536 fnid = self.runq_fnid[task]
537 if fnid not in reccumdepends: 537 if fnid not in reccumdepends:
538 if fnid in tdepends_fnid: 538 if fnid in tdepends_fnid:
@@ -540,7 +540,7 @@ class RunQueueData:
540 else: 540 else:
541 reccumdepends[fnid] = set() 541 reccumdepends[fnid] = set()
542 reccumdepends[fnid].update(self.runq_depends[task]) 542 reccumdepends[fnid].update(self.runq_depends[task])
543 for task in range(len(self.runq_fnid)): 543 for task in xrange(len(self.runq_fnid)):
544 taskfnid = self.runq_fnid[task] 544 taskfnid = self.runq_fnid[task]
545 for fnid in reccumdepends: 545 for fnid in reccumdepends:
546 if task in reccumdepends[fnid]: 546 if task in reccumdepends[fnid]:
@@ -553,7 +553,7 @@ class RunQueueData:
553 # 553 #
554 # e.g. do_sometask[recrdeptask] = "do_someothertask" 554 # e.g. do_sometask[recrdeptask] = "do_someothertask"
555 # (makes sure sometask runs after someothertask of all DEPENDS, RDEPENDS and intertask dependencies, recursively) 555 # (makes sure sometask runs after someothertask of all DEPENDS, RDEPENDS and intertask dependencies, recursively)
556 for task in range(len(self.runq_fnid)): 556 for task in xrange(len(self.runq_fnid)):
557 if len(runq_recrdepends[task]) > 0: 557 if len(runq_recrdepends[task]) > 0:
558 taskfnid = self.runq_fnid[task] 558 taskfnid = self.runq_fnid[task]
559 for dep in reccumdepends[taskfnid]: 559 for dep in reccumdepends[taskfnid]:
@@ -622,7 +622,7 @@ class RunQueueData:
622 622
623 maps = [] 623 maps = []
624 delcount = 0 624 delcount = 0
625 for listid in range(len(self.runq_fnid)): 625 for listid in xrange(len(self.runq_fnid)):
626 if runq_build[listid-delcount] == 1: 626 if runq_build[listid-delcount] == 1:
627 maps.append(listid-delcount) 627 maps.append(listid-delcount)
628 else: 628 else:
@@ -650,7 +650,7 @@ class RunQueueData:
650 650
651 # Remap the dependencies to account for the deleted tasks 651 # Remap the dependencies to account for the deleted tasks
652 # Check we didn't delete a task we depend on 652 # Check we didn't delete a task we depend on
653 for listid in range(len(self.runq_fnid)): 653 for listid in xrange(len(self.runq_fnid)):
654 newdeps = [] 654 newdeps = []
655 origdeps = self.runq_depends[listid] 655 origdeps = self.runq_depends[listid]
656 for origdep in origdeps: 656 for origdep in origdeps:
@@ -662,14 +662,14 @@ class RunQueueData:
662 logger.verbose("Assign Weightings") 662 logger.verbose("Assign Weightings")
663 663
664 # Generate a list of reverse dependencies to ease future calculations 664 # Generate a list of reverse dependencies to ease future calculations
665 for listid in range(len(self.runq_fnid)): 665 for listid in xrange(len(self.runq_fnid)):
666 for dep in self.runq_depends[listid]: 666 for dep in self.runq_depends[listid]:
667 self.runq_revdeps[dep].add(listid) 667 self.runq_revdeps[dep].add(listid)
668 668
669 # Identify tasks at the end of dependency chains 669 # Identify tasks at the end of dependency chains
670 # Error on circular dependency loops (length two) 670 # Error on circular dependency loops (length two)
671 endpoints = [] 671 endpoints = []
672 for listid in range(len(self.runq_fnid)): 672 for listid in xrange(len(self.runq_fnid)):
673 revdeps = self.runq_revdeps[listid] 673 revdeps = self.runq_revdeps[listid]
674 if len(revdeps) == 0: 674 if len(revdeps) == 0:
675 endpoints.append(listid) 675 endpoints.append(listid)
@@ -687,7 +687,7 @@ class RunQueueData:
687 # Sanity Check - Check for multiple tasks building the same provider 687 # Sanity Check - Check for multiple tasks building the same provider
688 prov_list = {} 688 prov_list = {}
689 seen_fn = [] 689 seen_fn = []
690 for task in range(len(self.runq_fnid)): 690 for task in xrange(len(self.runq_fnid)):
691 fn = taskData.fn_index[self.runq_fnid[task]] 691 fn = taskData.fn_index[self.runq_fnid[task]]
692 if fn in seen_fn: 692 if fn in seen_fn:
693 continue 693 continue
@@ -1191,7 +1191,7 @@ class RunQueueExecuteTasks(RunQueueExecute):
1191 self.stats = RunQueueStats(len(self.rqdata.runq_fnid)) 1191 self.stats = RunQueueStats(len(self.rqdata.runq_fnid))
1192 1192
1193 # Mark initial buildable tasks 1193 # Mark initial buildable tasks
1194 for task in range(self.stats.total): 1194 for task in xrange(self.stats.total):
1195 self.runq_running.append(0) 1195 self.runq_running.append(0)
1196 self.runq_complete.append(0) 1196 self.runq_complete.append(0)
1197 if len(self.rqdata.runq_depends[task]) == 0: 1197 if len(self.rqdata.runq_depends[task]) == 0:
@@ -1204,7 +1204,7 @@ class RunQueueExecuteTasks(RunQueueExecute):
1204 found = True 1204 found = True
1205 while found: 1205 while found:
1206 found = False 1206 found = False
1207 for task in range(self.stats.total): 1207 for task in xrange(self.stats.total):
1208 if task in self.rq.scenequeue_covered: 1208 if task in self.rq.scenequeue_covered:
1209 continue 1209 continue
1210 if len(self.rqdata.runq_revdeps[task]) > 0 and self.rqdata.runq_revdeps[task].issubset(self.rq.scenequeue_covered): 1210 if len(self.rqdata.runq_revdeps[task]) > 0 and self.rqdata.runq_revdeps[task].issubset(self.rq.scenequeue_covered):
@@ -1333,7 +1333,7 @@ class RunQueueExecuteTasks(RunQueueExecute):
1333 return True 1333 return True
1334 1334
1335 # Sanity Checks 1335 # Sanity Checks
1336 for task in range(self.stats.total): 1336 for task in xrange(self.stats.total):
1337 if self.runq_buildable[task] == 0: 1337 if self.runq_buildable[task] == 0:
1338 logger.error("Task %s never buildable!" % task) 1338 logger.error("Task %s never buildable!" % task)
1339 if self.runq_running[task] == 0: 1339 if self.runq_running[task] == 0:
@@ -1368,12 +1368,12 @@ class RunQueueExecuteScenequeue(RunQueueExecute):
1368 # therefore aims to collapse the huge runqueue dependency tree into a smaller one 1368 # therefore aims to collapse the huge runqueue dependency tree into a smaller one
1369 # only containing the setscene functions. 1369 # only containing the setscene functions.
1370 1370
1371 for task in range(self.stats.total): 1371 for task in xrange(self.stats.total):
1372 self.runq_running.append(0) 1372 self.runq_running.append(0)
1373 self.runq_complete.append(0) 1373 self.runq_complete.append(0)
1374 self.runq_buildable.append(0) 1374 self.runq_buildable.append(0)
1375 1375
1376 for task in range(len(self.rqdata.runq_fnid)): 1376 for task in xrange(len(self.rqdata.runq_fnid)):
1377 sq_revdeps.append(copy.copy(self.rqdata.runq_revdeps[task])) 1377 sq_revdeps.append(copy.copy(self.rqdata.runq_revdeps[task]))
1378 sq_revdeps_new.append(set()) 1378 sq_revdeps_new.append(set())
1379 if (len(self.rqdata.runq_revdeps[task]) == 0) and task not in self.rqdata.runq_setscene: 1379 if (len(self.rqdata.runq_revdeps[task]) == 0) and task not in self.rqdata.runq_setscene:
@@ -1404,7 +1404,7 @@ class RunQueueExecuteScenequeue(RunQueueExecute):
1404 1404
1405 process_endpoints(endpoints) 1405 process_endpoints(endpoints)
1406 1406
1407 for task in range(len(self.rqdata.runq_fnid)): 1407 for task in xrange(len(self.rqdata.runq_fnid)):
1408 if task in self.rqdata.runq_setscene: 1408 if task in self.rqdata.runq_setscene:
1409 deps = set() 1409 deps = set()
1410 for dep in sq_revdeps_new[task]: 1410 for dep in sq_revdeps_new[task]:
@@ -1413,20 +1413,20 @@ class RunQueueExecuteScenequeue(RunQueueExecute):
1413 elif len(sq_revdeps_new[task]) != 0: 1413 elif len(sq_revdeps_new[task]) != 0:
1414 bb.msg.fatal(bb.msg.domain.RunQueue, "Something went badly wrong during scenequeue generation, aborting. Please report this problem.") 1414 bb.msg.fatal(bb.msg.domain.RunQueue, "Something went badly wrong during scenequeue generation, aborting. Please report this problem.")
1415 1415
1416 #for task in range(len(sq_revdeps_squash)): 1416 #for task in xrange(len(sq_revdeps_squash)):
1417 # print "Task %s: %s.%s is %s " % (task, self.taskData.fn_index[self.runq_fnid[self.runq_setscene[task]]], self.runq_task[self.runq_setscene[task]] + "_setscene", sq_revdeps_squash[task]) 1417 # print "Task %s: %s.%s is %s " % (task, self.taskData.fn_index[self.runq_fnid[self.runq_setscene[task]]], self.runq_task[self.runq_setscene[task]] + "_setscene", sq_revdeps_squash[task])
1418 1418
1419 self.sq_deps = [] 1419 self.sq_deps = []
1420 self.sq_revdeps = sq_revdeps_squash 1420 self.sq_revdeps = sq_revdeps_squash
1421 self.sq_revdeps2 = copy.deepcopy(self.sq_revdeps) 1421 self.sq_revdeps2 = copy.deepcopy(self.sq_revdeps)
1422 1422
1423 for task in range(len(self.sq_revdeps)): 1423 for task in xrange(len(self.sq_revdeps)):
1424 self.sq_deps.append(set()) 1424 self.sq_deps.append(set())
1425 for task in range(len(self.sq_revdeps)): 1425 for task in xrange(len(self.sq_revdeps)):
1426 for dep in self.sq_revdeps[task]: 1426 for dep in self.sq_revdeps[task]:
1427 self.sq_deps[dep].add(task) 1427 self.sq_deps[dep].add(task)
1428 1428
1429 for task in range(len(self.sq_revdeps)): 1429 for task in xrange(len(self.sq_revdeps)):
1430 if len(self.sq_revdeps[task]) == 0: 1430 if len(self.sq_revdeps[task]) == 0:
1431 self.runq_buildable[task] = 1 1431 self.runq_buildable[task] = 1
1432 1432
@@ -1437,7 +1437,7 @@ class RunQueueExecuteScenequeue(RunQueueExecute):
1437 sq_taskname = [] 1437 sq_taskname = []
1438 sq_task = [] 1438 sq_task = []
1439 noexec = [] 1439 noexec = []
1440 for task in range(len(self.sq_revdeps)): 1440 for task in xrange(len(self.sq_revdeps)):
1441 realtask = self.rqdata.runq_setscene[task] 1441 realtask = self.rqdata.runq_setscene[task]
1442 fn = self.rqdata.taskData.fn_index[self.rqdata.runq_fnid[realtask]] 1442 fn = self.rqdata.taskData.fn_index[self.rqdata.runq_fnid[realtask]]
1443 taskname = self.rqdata.runq_task[realtask] 1443 taskname = self.rqdata.runq_task[realtask]
@@ -1460,7 +1460,7 @@ class RunQueueExecuteScenequeue(RunQueueExecute):
1460 for v in valid: 1460 for v in valid:
1461 valid_new.append(sq_task[v]) 1461 valid_new.append(sq_task[v])
1462 1462
1463 for task in range(len(self.sq_revdeps)): 1463 for task in xrange(len(self.sq_revdeps)):
1464 if task not in valid_new and task not in noexec: 1464 if task not in valid_new and task not in noexec:
1465 logger.debug(2, "No package found so skipping setscene task %s" % (self.rqdata.get_user_idstring(self.rqdata.runq_setscene[task]))) 1465 logger.debug(2, "No package found so skipping setscene task %s" % (self.rqdata.get_user_idstring(self.rqdata.runq_setscene[task])))
1466 self.task_failoutright(task) 1466 self.task_failoutright(task)
@@ -1525,7 +1525,7 @@ class RunQueueExecuteScenequeue(RunQueueExecute):
1525 task = None 1525 task = None
1526 if self.stats.active < self.number_tasks: 1526 if self.stats.active < self.number_tasks:
1527 # Find the next setscene to run 1527 # Find the next setscene to run
1528 for nexttask in range(self.stats.total): 1528 for nexttask in xrange(self.stats.total):
1529 if self.runq_buildable[nexttask] == 1 and self.runq_running[nexttask] != 1: 1529 if self.runq_buildable[nexttask] == 1 and self.runq_running[nexttask] != 1:
1530 #bb.note("Comparing %s to %s" % (self.sq_revdeps[nexttask], self.scenequeue_covered)) 1530 #bb.note("Comparing %s to %s" % (self.sq_revdeps[nexttask], self.scenequeue_covered))
1531 #if len(self.sq_revdeps[nexttask]) > 0 and self.sq_revdeps[nexttask].issubset(self.scenequeue_covered): 1531 #if len(self.sq_revdeps[nexttask]) > 0 and self.sq_revdeps[nexttask].issubset(self.scenequeue_covered):