summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2019-12-21 23:45:47 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2019-12-23 18:36:56 -0800
commitd7f2a32887e8c05707ca3d9139a0a850d264222b (patch)
treed1090802d38a378e320bf67a2f51ca706a6e8cb8
parent78b84e4adecc18f8e92844b11a627c54ac2ef7c8 (diff)
downloadspack-d7f2a32887e8c05707ca3d9139a0a850d264222b.tar.gz
spack-d7f2a32887e8c05707ca3d9139a0a850d264222b.tar.bz2
spack-d7f2a32887e8c05707ca3d9139a0a850d264222b.tar.xz
spack-d7f2a32887e8c05707ca3d9139a0a850d264222b.zip
performance: dont' read `spec.yaml` files twice in view regeneration
`ViewDescriptor.regenerate()` calls `get_all_specs()`, which reads `spec.yaml` files, which is slow. It's fine to do this once, but `view.remove_specs()` *also* calls it immediately afterwards. - [x] Pass the result of `get_all_specs()` as an optional parameter to `view.remove_specs()` to avoid reading `spec.yaml` files twice.
-rw-r--r--lib/spack/spack/environment.py7
-rw-r--r--lib/spack/spack/filesystem_view.py5
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/spack/spack/environment.py b/lib/spack/spack/environment.py
index b09cf7c7db..b0d17877dc 100644
--- a/lib/spack/spack/environment.py
+++ b/lib/spack/spack/environment.py
@@ -534,9 +534,12 @@ class ViewDescriptor(object):
tty.msg("Updating view at {0}".format(self.root))
rm_specs = specs_in_view - installed_specs_for_view
- view.remove_specs(*rm_specs, with_dependents=False)
-
add_specs = installed_specs_for_view - specs_in_view
+
+ # pass all_specs in, as it's expensive to read all the
+ # spec.yaml files twice.
+ view.remove_specs(*rm_specs, with_dependents=False,
+ all_specs=specs_in_view)
view.add_specs(*add_specs, with_dependencies=False)
diff --git a/lib/spack/spack/filesystem_view.py b/lib/spack/spack/filesystem_view.py
index 448254f26b..5455ccb107 100644
--- a/lib/spack/spack/filesystem_view.py
+++ b/lib/spack/spack/filesystem_view.py
@@ -371,6 +371,9 @@ class YamlFilesystemView(FilesystemView):
with_dependents = kwargs.get("with_dependents", True)
with_dependencies = kwargs.get("with_dependencies", False)
+ # caller can pass this in, as get_all_specs() is expensive
+ all_specs = kwargs.get("all_specs", None) or set(self.get_all_specs())
+
specs = set(specs)
if with_dependencies:
@@ -379,8 +382,6 @@ class YamlFilesystemView(FilesystemView):
if kwargs.get("exclude", None):
specs = set(filter_exclude(specs, kwargs["exclude"]))
- all_specs = set(self.get_all_specs())
-
to_deactivate = specs
to_keep = all_specs - to_deactivate