From 3f5bed2e36640798c6d1d7097885e8411931f1a6 Mon Sep 17 00:00:00 2001 From: Andrew W Elble Date: Mon, 27 Jan 2020 23:53:52 -0500 Subject: make the new 'spack load' faster (#14628) before, a 'time spack load singularity' 4.129u 0.346s 0:04.47 99.7% 0+0k 0+8io 0pf+0w after, a 'time spack load singularity' 0.844u 0.319s 0:01.16 99.1% 0+0k 0+16io 0pf+0w --- lib/spack/spack/cmd/load.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/cmd/load.py b/lib/spack/spack/cmd/load.py index 80c7263a7a..09f3fd31ee 100644 --- a/lib/spack/spack/cmd/load.py +++ b/lib/spack/spack/cmd/load.py @@ -12,6 +12,7 @@ import spack.cmd.common.arguments as arguments import spack.environment as ev import spack.util.environment import spack.user_environment as uenv +import spack.store description = "add package to the user environment" section = "user environment" @@ -63,15 +64,17 @@ def load(parser, args): tty.msg(*msg) return 1 - if 'dependencies' in args.things_to_load: - include_roots = 'package' in args.things_to_load - specs = [dep for spec in specs - for dep in spec.traverse(root=include_roots, order='post')] + with spack.store.db.read_transaction(): + if 'dependencies' in args.things_to_load: + include_roots = 'package' in args.things_to_load + specs = [dep for spec in specs + for dep in + spec.traverse(root=include_roots, order='post')] - env_mod = spack.util.environment.EnvironmentModifications() - for spec in specs: - env_mod.extend(uenv.environment_modifications_for_spec(spec)) - env_mod.prepend_path(uenv.spack_loaded_hashes_var, spec.dag_hash()) - cmds = env_mod.shell_modifications(args.shell) + env_mod = spack.util.environment.EnvironmentModifications() + for spec in specs: + env_mod.extend(uenv.environment_modifications_for_spec(spec)) + env_mod.prepend_path(uenv.spack_loaded_hashes_var, spec.dag_hash()) + cmds = env_mod.shell_modifications(args.shell) - sys.stdout.write(cmds) + sys.stdout.write(cmds) -- cgit v1.2.3-60-g2f50