[Piuparts-commits] [SCM] piuparts git repository branch, develop, updated. 0.49-85-g07ca11e
Holger Levsen
holger at layer-acht.org
Sat Feb 23 16:56:48 UTC 2013
The following commit has been merged in the develop branch:
commit 07ca11ee69360a972d9734d409ea21bd4c2b7ef2
Author: Andreas Beckmann <anbe at debian.org>
Date: Sat Feb 23 13:25:46 2013 +0100
lib/db: remove reserved packages from candidates
avoid rrdeps computation if not needed
avoid O(n^2) looping over previously reserved packages
Signed-off-by: Andreas Beckmann <anbe at debian.org>
diff --git a/debian/changelog b/debian/changelog
index d0429ca..fc959c0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -20,6 +20,7 @@ piuparts (0.50) UNRELEASED; urgency=low
* piupartslib/conf.py:
* piupartslib/packagesdb.py:
- Add Package.waiting_count() and friends, populated in calc_rrdep_count.
+ - Optimize reserve() and skip unavailable candidates.
* piuparts-master.py:
- Sort packages to be tested by importance, i.e. descending waiting_count.
* piuparts-slave.py:
diff --git a/piupartslib/packagesdb.py b/piupartslib/packagesdb.py
index e752758..48db1e2 100644
--- a/piupartslib/packagesdb.py
+++ b/piupartslib/packagesdb.py
@@ -643,6 +643,9 @@ class PackagesDB:
if self._candidates_for_testing is None:
self._candidates_for_testing = [self.get_package(pn)
for pn in self.get_pkg_names_in_state("waiting-to-be-tested")]
+ self._candidates_for_testing = [p for p in self._candidates_for_testing
+ if not self._logdb.log_exists(p, [self._reserved]) or \
+ self._logdb.log_exists(p, [self._recycle])]
if len(self._candidates_for_testing) > 1:
self.calc_rrdep_counts()
tuples = [(p.waiting_count(), random.random(), p)
@@ -651,6 +654,9 @@ class PackagesDB:
for x in sorted(tuples, reverse = True)]
return self._candidates_for_testing
+ def _remove_unavailable_candidate(self, p):
+ self._candidates_for_testing.remove(p)
+
def reserve_package(self):
all_but_recycle = [x for x in self._all if x != self._recycle]
for p in self._find_packages_ready_for_testing():
@@ -660,6 +666,7 @@ class PackagesDB:
self._logdb.remove(vdir, p["Package"], p["Version"])
logging.info("Recycled %s %s %s" % (vdir, p["Package"], p["Version"]))
if self._logdb.log_exists(p, all_but_recycle):
+ self._remove_unavailable_candidate(p)
continue
if self._logdb.log_exists(p, [self._recycle]):
self._logdb.remove(self._recycle, p["Package"], p["Version"])
--
piuparts git repository
More information about the Piuparts-commits
mailing list