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
This commit is contained in:
Andrew W Elble 2020-01-27 23:53:52 -05:00 committed by Todd Gamblin
parent f58004e436
commit 3f5bed2e36

View File

@ -12,6 +12,7 @@
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)