Remove single-root assertion from Spec.root

- Assertion would search for root through all possible paths.
  - It's also really slow.

- This isn't needed anymore. We're pretty good at ensuring single-rooted
  DAGs, and this assertion has never been thrown.

- This shaves another 6 seconds off r-rminer concretization
This commit is contained in:
Todd Gamblin 2017-10-13 17:20:23 -07:00
parent 3f091fb6db
commit afc99ca516
2 changed files with 6 additions and 11 deletions

View file

@ -113,7 +113,9 @@ def choose_virtual_or_external(self, spec):
# Find the nearest spec in the dag that has a compiler. We'll # Find the nearest spec in the dag that has a compiler. We'll
# use that spec to calibrate compiler compatibility. # use that spec to calibrate compiler compatibility.
abi_exemplar = find_spec(spec, lambda x: x.compiler, spec.root) abi_exemplar = find_spec(spec, lambda x: x.compiler)
if abi_exemplar is None:
abi_exemplar = spec.root
# Sort candidates from most to least compatibility. # Sort candidates from most to least compatibility.
# We reverse because True > False. # We reverse because True > False.

View file

@ -1178,20 +1178,13 @@ def fullname(self):
@property @property
def root(self): def root(self):
"""Follow dependent links and find the root of this spec's DAG. """Follow dependent links and find the root of this spec's DAG.
In spack specs, there should be a single root (the package being
installed). This will throw an assertion error if that is not Spack specs have a single root (the package being installed).
the case.
""" """
if not self._dependents: if not self._dependents:
return self return self
# If the spec has multiple dependents, ensure that they all return next(iter(self._dependents.values())).parent.root
# lead to the same place. Spack shouldn't deal with any DAGs
# with multiple roots, so something's wrong if we find one.
depiter = iter(self._dependents.values())
first_root = next(depiter).parent.root
assert(all(first_root is d.parent.root for d in depiter))
return first_root
@property @property
def package(self): def package(self):