summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2019-12-16 17:37:47 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2019-12-23 23:17:58 -0800
commitcbf8553406c9b7d7ec529751f39ebbad331cbdc7 (patch)
tree544733aeaca23a2a6a501d064d2abbe4bf09badc
parent48befd67b565efcb218849644c9dc1f728e2f095 (diff)
downloadspack-cbf8553406c9b7d7ec529751f39ebbad331cbdc7.tar.gz
spack-cbf8553406c9b7d7ec529751f39ebbad331cbdc7.tar.bz2
spack-cbf8553406c9b7d7ec529751f39ebbad331cbdc7.tar.xz
spack-cbf8553406c9b7d7ec529751f39ebbad331cbdc7.zip
concretization: improve performance by avoiding database locks
Checks for deprecated specs were repeatedly taking out read locks on the database, which can be very slow. - [x] put a read transaction around the deprecation check
-rw-r--r--lib/spack/spack/spec.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 050f027679..86ac62e0d7 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -2243,10 +2243,12 @@ class Spec(object):
# If any spec in the DAG is deprecated, throw an error
deprecated = []
- for x in self.traverse():
- _, rec = spack.store.db.query_by_spec_hash(x.dag_hash())
- if rec and rec.deprecated_for:
- deprecated.append(rec)
+ with spack.store.db.read_transaction():
+ for x in self.traverse():
+ _, rec = spack.store.db.query_by_spec_hash(x.dag_hash())
+ if rec and rec.deprecated_for:
+ deprecated.append(rec)
+
if deprecated:
msg = "\n The following specs have been deprecated"
msg += " in favor of specs with the hashes shown:\n"