performance: add read transactions for install_all()
and install()
Environments need to read the DB a lot when installing all specs. - [x] Put a read transaction around `install_all()` and `install()` to avoid repeated locking
This commit is contained in:
parent
d87ededddc
commit
be6d7db2a8
@ -992,13 +992,16 @@ def install(self, user_spec, concrete_spec=None, **install_args):
|
||||
|
||||
spec = Spec(user_spec)
|
||||
|
||||
with spack.store.db.read_transaction():
|
||||
if self.add(spec):
|
||||
concrete = concrete_spec if concrete_spec else spec.concretized()
|
||||
concrete = concrete_spec or spec.concretized()
|
||||
self._add_concrete_spec(spec, concrete)
|
||||
else:
|
||||
# spec might be in the user_specs, but not installed.
|
||||
# TODO: Redo name-based comparison for old style envs
|
||||
spec = next(s for s in self.user_specs if s.satisfies(user_spec))
|
||||
spec = next(
|
||||
s for s in self.user_specs if s.satisfies(user_spec)
|
||||
)
|
||||
concrete = self.specs_by_hash.get(spec.build_hash())
|
||||
if not concrete:
|
||||
concrete = spec.concretized()
|
||||
@ -1177,6 +1180,7 @@ def _add_concrete_spec(self, spec, concrete, new=True):
|
||||
|
||||
def install_all(self, args=None):
|
||||
"""Install all concretized specs in an environment."""
|
||||
with spack.store.db.read_transaction():
|
||||
for concretized_hash in self.concretized_order:
|
||||
spec = self.specs_by_hash[concretized_hash]
|
||||
|
||||
@ -1190,8 +1194,8 @@ def install_all(self, args=None):
|
||||
|
||||
if not spec.external:
|
||||
# Link the resulting log file into logs dir
|
||||
build_log_link = os.path.join(
|
||||
self.log_path, '%s-%s.log' % (spec.name, spec.dag_hash(7)))
|
||||
log_name = '%s-%s' % (spec.name, spec.dag_hash(7))
|
||||
build_log_link = os.path.join(self.log_path, log_name)
|
||||
if os.path.lexists(build_log_link):
|
||||
os.remove(build_log_link)
|
||||
os.symlink(spec.package.build_log_path, build_log_link)
|
||||
|
Loading…
Reference in New Issue
Block a user