summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2019-12-21 23:45:30 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2019-12-23 23:18:46 -0800
commite3939b0c72b2c6bc5f41e9f33de3c04cf4785c05 (patch)
tree13b54a5616dee4058162629be88817afd3a74dd6
parentf01368739741ef9b3bcc827f7dbc2ab9d5b48df4 (diff)
downloadspack-e3939b0c72b2c6bc5f41e9f33de3c04cf4785c05.tar.gz
spack-e3939b0c72b2c6bc5f41e9f33de3c04cf4785c05.tar.bz2
spack-e3939b0c72b2c6bc5f41e9f33de3c04cf4785c05.tar.xz
spack-e3939b0c72b2c6bc5f41e9f33de3c04cf4785c05.zip
performance: don't recompute hashes when regenerating environments
`ViewDescriptor.regenerate()` was copying specs and stripping build dependencies, which clears `_hash` and other cached fields on concrete specs, which causes a bunch of YAML hashes to be recomputed. - [x] Preserve the `_hash` and `_normal` fields on stripped specs, as these will be unchanged.
-rw-r--r--lib/spack/spack/environment.py11
-rw-r--r--lib/spack/spack/spec.py2
2 files changed, 9 insertions, 4 deletions
diff --git a/lib/spack/spack/environment.py b/lib/spack/spack/environment.py
index 5b526bbe11..56440fbe92 100644
--- a/lib/spack/spack/environment.py
+++ b/lib/spack/spack/environment.py
@@ -511,10 +511,15 @@ class ViewDescriptor(object):
specs = all_specs if self.link == 'all' else roots
for spec in specs:
# The view does not store build deps, so if we want it to
- # recognize environment specs (which do store build deps), then
- # they need to be stripped
+ # recognize environment specs (which do store build deps),
+ # then they need to be stripped.
if spec.concrete: # Do not link unconcretized roots
- specs_for_view.append(spec.copy(deps=('link', 'run')))
+ # We preserve _hash _normal to avoid recomputing DAG
+ # hashes (DAG hashes don't consider build deps)
+ spec_copy = spec.copy(deps=('link', 'run'))
+ spec_copy._hash = spec._hash
+ spec_copy._normal = spec._normal
+ specs_for_view.append(spec_copy)
# regeneration queries the database quite a bit; this read
# transaction ensures that we don't repeatedly lock/unlock.
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 86ac62e0d7..c553da796d 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -2999,7 +2999,7 @@ class Spec(object):
before possibly copying the dependencies of ``other`` onto
``self``
caches (bool or None): preserve cached fields such as
- ``_normal``, ``_concrete``, and ``_cmp_key_cache``. By
+ ``_normal``, ``_hash``, and ``_cmp_key_cache``. By
default this is ``False`` if DAG structure would be
changed by the copy, ``True`` if it's an exact copy.