WIP, ENH: add spack load runtimeonly#25723
WIP, ENH: add spack load runtimeonly#25723tylerjereddy wants to merge 1 commit intospack:developfrom
Conversation
* add a `--runtimeonly` option to `spack load` so that we can quickly load dependencies for builds outside of `spack` that depend on the `specs` installed by `spack` * internal testing shows a 40-fold speedup with: `spack load -r --runtimeonly collected_deps_package` * does not contain regression tests/docs yet, pending review of whether `spack` team would actually want this, etc. * note that for our internal use case we also have to adjust `modules.yaml` to generate `CPATH` for our CMake build per changes in: https://github.com/spack/spack/pull/14749/files https://github.com/spack/spack/pull/21699/files
|
CI failure is: |
|
I don't think this is the way to go:
What has to be addressed is this: a) And potentially this: b) * As a side-note, it's weird that we have duplicate options for |
Yeah, I wasn't really trying to fix that bug, which is why I don't claim to fix the second connected issue above. If you think fixing those other issues is really going to be cleaner and more performant for the specific use case of a fast path to recursive loading I could take a look. I think my intuition was just to avoid doing surgery on currently tested code and just provide a fast path to what I need.
Maybe stricter "orthogonality" rules might be needed for the In the original patch I provided I did selectively disable some of the things you mention, but it sounded like we didn't want to adjust that based on feedback at: #25306 (comment) So, you do want to start hacking around inside of |
Sorry for the confusion, and you're right, at that point I thought I have the impression that wherever Notably in for env_var in env_mod.group_by_name():
env_mod.prune_duplicate_paths(env_var)this also explains @adamjstewart's comment #25306 (comment). Also, the only reason So, I think what we can do is drop the recursion to dependencies in Edit: this is a huge rabbit hole unfortunately :( |
|
Coming back to this PR after going through the Spack internals and git history:
This turned out to be only partially true. It recursively calls Before that discussion is settled, I've submitted a PR to make Then my preferred way of speeding up Can you maybe verify that 25732 on top of 25755 gives you a reasonable speedup for Finally, w.r.t. my previous comment
that was one way of doing things, but it's awkward to call |
|
@haampie Ok, I'll try to take a look at the performance on our internal use case today. I'm guessing |
|
No, we don't have that, but that looks great! As a side note: I think spack load hasn't received a whole lot of attention since environments became a thing, maybe you could use that for your day to day use as a replacement |
|
FWIW, I can simplify to not add a new --- a/lib/spack/spack/cmd/load.py
+++ b/lib/spack/spack/cmd/load.py
@@ -75,9 +75,22 @@ def load(parser, args):
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())
+
+ if args.recurse_dependencies:
+ # fast path for `spack load -r`
+ for spec in specs:
+ env = spack.util.environment.inspect_path(
+ spec.prefix,
+ uenv.prefix_inspections(spec.platform),
+ exclude=spack.util.environment.is_system_path
+ )
+ spec.package.setup_run_environment(env)
+ env_mod.extend(env)
+ else:
+ 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)
|
|
Note that there are two bugs/issues in your patch:
So yes, this has to be fixed properly and the above fast path can't be merged |
|
Thanks, sounds good--I'll close this--it does pass our local testing just fine. Perhaps when the code paths are better covered by regression tests it will be easier for us to help out here, but if we can't depend on the tests to find issues when iterating it seems like this is best left to the core team to patch for now. |
Fixes #25669
Related to discussion in #25306
cc @haampie @adamjstewart @junghans @cferenba @clellsolomon
add a
--runtimeonlyoption tospack loadso thatwe can quickly load dependencies for builds outside of
spackthat depend on thespecsinstalled byspackinternal testing shows a 20-fold speedup with:
spack load -r --runtimeonly collected_deps_packagedoes not contain regression tests/docs yet, pending review
of whether
spackteam would actually want this, etc.note that for our internal use case we also have
to adjust
modules.yamlto generateCPATHfor ourCMake build per changes in:
https://github.com/spack/spack/pull/14749/files
https://github.com/spack/spack/pull/21699/files