[Piuparts-devel] lib/db: sort packages returned by reserve() by importance
Dave Steele
dsteele at gmail.com
Thu Feb 21 18:07:30 UTC 2013
def _find_packages_ready_for_testing(self):
- return self.get_pkg_names_in_state("waiting-to-be-tested")
+ if self._candidates_for_testing is None:
+ package_names = self.get_pkg_names_in_state("waiting-to-be-tested")
+ if len(package_names) > 1:
+ self.calc_rrdep_counts()
+ tuples = [(self.get_package(pn).waiting_count(),
random.random(), pn)
+ for pn in package_names]
+ self._candidates_for_testing = [self.get_package(x[2])
+ for x in sorted(tuples, reverse = True)]
+ else:
+ self._candidates_for_testing = [self.get_package(pn)
+ for pn in package_names]
+ return self._candidates_for_testing
I've been wanting to do this, but was worried about conversations re
the delay in calc_rrdep_counts(). Note that it may be sped up ~2X for
smaller package_names lists by saving rrdep_list and moving some of
the calculation logic to e.g. waiting_count().
Maybe more - the algorithm will weed out the high-rdep packages early.
More information about the Piuparts-devel
mailing list