performance: speed up spack find
in environments
`Environment.added_specs()` has a loop around calls to `Package.installed()`, which can result in repeated DB queries. Optimize this with a read transaction in `Environment`.
This commit is contained in:
parent
0e9c8d236c
commit
a3799b2c7b
@ -25,6 +25,7 @@
|
||||
import spack.repo
|
||||
import spack.schema.env
|
||||
import spack.spec
|
||||
import spack.store
|
||||
import spack.util.spack_json as sjson
|
||||
import spack.util.spack_yaml as syaml
|
||||
import spack.config
|
||||
@ -1235,6 +1236,9 @@ def added_specs(self):
|
||||
Yields the user spec for non-concretized specs, and the concrete
|
||||
spec for already concretized but not yet installed specs.
|
||||
"""
|
||||
# use a transaction to avoid overhead of repeated calls
|
||||
# to `package.installed`
|
||||
with spack.store.db.read_transaction():
|
||||
concretized = dict(self.concretized_specs())
|
||||
for spec in self.user_specs:
|
||||
concrete = concretized.get(spec)
|
||||
|
Loading…
Reference in New Issue
Block a user