inst-tester: Remove obsolete "safe-set" optimization

Signed-off-by: Niels Thykier <niels@thykier.net>
ubuntu/rebased
Niels Thykier 6 years ago
parent 95b945d2b3
commit cd1f384012
No known key found for this signature in database
GPG Key ID: A65B78DBE67C7AAC

@ -228,21 +228,10 @@ class InstallabilityTesterBuilder(object):
package_table = self._package_table package_table = self._package_table
reverse_package_table = self._reverse_package_table reverse_package_table = self._reverse_package_table
intern_set = self._intern_set intern_set = self._intern_set
safe_set = set()
broken = self._broken broken = self._broken
not_broken = ifilter_except(broken) not_broken = ifilter_except(broken)
check = set(broken) check = set(broken)
def safe_set_satisfies(t):
"""Check if t's dependencies can be satisfied by the safe set"""
if not package_table[t][0]:
# If it has no dependencies at all, then it is safe. :)
return True
for depgroup in package_table[t][0]:
if not any(dep for dep in depgroup if dep in safe_set):
return False
return True
# Merge reverse conflicts with conflicts - this saves some # Merge reverse conflicts with conflicts - this saves some
# operations in _check_loop since we only have to check one # operations in _check_loop since we only have to check one
# set (instead of two) and we remove a few duplicates here # set (instead of two) and we remove a few duplicates here
@ -306,38 +295,13 @@ class InstallabilityTesterBuilder(object):
if b in reverse_package_table: if b in reverse_package_table:
del reverse_package_table[b] del reverse_package_table[b]
# Now find an initial safe set (if any) eqv_table = self._build_eqv_packages_table(package_table, reverse_package_table)
check = set()
for pkg in package_table:
if package_table[pkg][1]:
# has (reverse) conflicts - not safe
continue
if not safe_set_satisfies(pkg):
continue
safe_set.add(pkg)
if pkg in reverse_package_table:
# add all rdeps (except those already in the safe_set)
check.update(reverse_package_table[pkg][0] - safe_set)
# Check if we can expand the initial safe set
for pkg in iter_except(check.pop, KeyError):
if package_table[pkg][1]:
# has (reverse) conflicts - not safe
continue
if safe_set_satisfies(pkg):
safe_set.add(pkg)
if pkg in reverse_package_table:
# add all rdeps (except those already in the safe_set)
check.update(reverse_package_table[pkg][0] - safe_set)
eqv_table = self._build_eqv_packages_table(package_table,
reverse_package_table)
return InstallabilitySolver(package_table, return InstallabilitySolver(package_table,
reverse_package_table, reverse_package_table,
self._testing, self._broken, self._testing,
self._essentials, safe_set, self._broken,
self._essentials,
eqv_table) eqv_table)
def _build_eqv_packages_table(self, package_table, def _build_eqv_packages_table(self, package_table,

@ -133,7 +133,7 @@ def compute_scc(graph):
class InstallabilitySolver(InstallabilityTester): class InstallabilitySolver(InstallabilityTester):
def __init__(self, universe, revuniverse, testing, broken, essentials, def __init__(self, universe, revuniverse, testing, broken, essentials,
safe_set, eqv_table): eqv_table):
"""Create a new installability solver """Create a new installability solver
universe is a dict mapping package tuples to their universe is a dict mapping package tuples to their
@ -153,7 +153,7 @@ class InstallabilitySolver(InstallabilityTester):
(simplifies caches and dependency checking) (simplifies caches and dependency checking)
""" """
super().__init__(universe, revuniverse, testing, super().__init__(universe, revuniverse, testing,
broken, essentials, safe_set, eqv_table) broken, essentials, eqv_table)
def solve_groups(self, groups): def solve_groups(self, groups):
sat_in_testing = self._testing.isdisjoint sat_in_testing = self._testing.isdisjoint

@ -23,7 +23,7 @@ from britney2.utils import iter_except
class InstallabilityTester(object): class InstallabilityTester(object):
def __init__(self, universe, revuniverse, testing, broken, essentials, def __init__(self, universe, revuniverse, testing, broken, essentials,
safe_set, eqv_table): eqv_table):
"""Create a new installability tester """Create a new installability tester
universe is a dict mapping package ids to their universe is a dict mapping package ids to their
@ -40,10 +40,6 @@ class InstallabilityTester(object):
essentials is a set of packages with "Essential: yes". essentials is a set of packages with "Essential: yes".
safe_set is a set of all packages which have no conflicts and
either have no dependencies or only depends on other "safe"
packages.
Package id: (pkg_name, pkg_version, pkg_arch) Package id: (pkg_name, pkg_version, pkg_arch)
- NB: arch:all packages are "re-mapped" to given architecture. - NB: arch:all packages are "re-mapped" to given architecture.
(simplifies caches and dependency checking) (simplifies caches and dependency checking)
@ -54,7 +50,6 @@ class InstallabilityTester(object):
self._broken = broken self._broken = broken
self._essentials = essentials self._essentials = essentials
self._revuniverse = revuniverse self._revuniverse = revuniverse
self._safe_set = safe_set
self._eqv_table = eqv_table self._eqv_table = eqv_table
self._stats = InstallabilityStats() self._stats = InstallabilityStats()
logger_name = ".".join((self.__class__.__module__, self.__class__.__name__)) logger_name = ".".join((self.__class__.__module__, self.__class__.__name__))
@ -258,14 +253,10 @@ class InstallabilityTester(object):
def _check_inst(self, t, musts=None, never=None, choices=None): def _check_inst(self, t, musts=None, never=None, choices=None):
# See the explanation of musts, never and choices below. # See the explanation of musts, never and choices below.
cache_inst = self._cache_inst
stats = self._stats stats = self._stats
universe = self._universe universe = self._universe
testing = self._testing testing = self._testing
cbroken = self._cache_broken cbroken = self._cache_broken
safe_set = self._safe_set
eqv_table = self._eqv_table eqv_table = self._eqv_table
# Our installability verdict - start with "yes" and change if # Our installability verdict - start with "yes" and change if
@ -353,23 +344,6 @@ class InstallabilityTester(object):
# is smaller than testing (so presumably faster) # is smaller than testing (so presumably faster)
remain = choice - never - cbroken remain = choice - never - cbroken
if len(remain) > 1 and not remain.isdisjoint(safe_set):
first = None
for r in filter(safe_set.__contains__, remain):
# don't bother giving extra arguments to _check_inst. "safe" packages are
# usually trivial to satisfy on their own and will not involve conflicts
# (so never will not help)
if r in cache_inst or self._check_inst(r):
first = r
break
if first:
musts.add(first)
check.add(first)
stats.choice_resolved_using_safe_set += 1
continue
# None of the safe set choices are installable, so drop them
remain -= safe_set
if len(remain) == 1: if len(remain) == 1:
# the choice was reduced to one package we haven't checked - check that # the choice was reduced to one package we haven't checked - check that
check.update(remain) check.update(remain)
@ -664,7 +638,6 @@ class InstallabilityStats(object):
self.backtrace_restore_point_used = 0 self.backtrace_restore_point_used = 0
self.backtrace_last_option = 0 self.backtrace_last_option = 0
self.choice_presolved = 0 self.choice_presolved = 0
self.choice_resolved_using_safe_set = 0
self.choice_resolved_without_restore_point = 0 self.choice_resolved_without_restore_point = 0
self.is_installable_calls = 0 self.is_installable_calls = 0
self.solved_installable = 0 self.solved_installable = 0
@ -679,7 +652,7 @@ class InstallabilityStats(object):
formats = [ formats = [
"Requests - is_installable: {is_installable_calls}", "Requests - is_installable: {is_installable_calls}",
"Cache - hits: {cache_hits}, misses: {cache_misses}, drops: {cache_drops}", "Cache - hits: {cache_hits}, misses: {cache_misses}, drops: {cache_drops}",
"Choices - pre-solved: {choice_presolved}, safe-set: {choice_resolved_using_safe_set}, No RP: {choice_resolved_without_restore_point}", "Choices - pre-solved: {choice_presolved}, No RP: {choice_resolved_without_restore_point}",
"Backtrace - RP created: {backtrace_restore_point_created}, RP used: {backtrace_restore_point_used}, reached last option: {backtrace_last_option}", "Backtrace - RP created: {backtrace_restore_point_created}, RP used: {backtrace_restore_point_used}, reached last option: {backtrace_last_option}",
"Solved - installable: {solved_installable}, uninstallable: {solved_uninstallable}, conflicts essential: {conflicts_essential}", "Solved - installable: {solved_installable}, uninstallable: {solved_uninstallable}, conflicts essential: {conflicts_essential}",
"Eqv - times used: {eqv_table_times_used}, perfect reductions: {eqv_table_reduced_to_one}, failed reductions: {eqv_table_reduced_by_zero}, total no. of alternatives pruned: {eqv_table_total_number_of_alternatives_eliminated}", "Eqv - times used: {eqv_table_times_used}, perfect reductions: {eqv_table_reduced_to_one}, failed reductions: {eqv_table_reduced_by_zero}, total no. of alternatives pruned: {eqv_table_total_number_of_alternatives_eliminated}",

Loading…
Cancel
Save