Skip to content

make spack setup-env lazy#9108

Closed
trws wants to merge 1 commit intospack:developfrom
trws:fast-source
Closed

make spack setup-env lazy#9108
trws wants to merge 1 commit intospack:developfrom
trws:fast-source

Conversation

@trws
Copy link
Copy Markdown
Contributor

@trws trws commented Aug 28, 2018

On a VM with a shared FS, or a system with NFS, this takes setup-env.sh from ~2 seconds to ~ 0.05 seconds (under and over-estimates respectively). It seems like it might be worthwhile to just cache these things given an option, or have a standard location that gets used and cleared, anyway, thoughts on making env loading lazy?

@trws
Copy link
Copy Markdown
Contributor Author

trws commented Aug 28, 2018

Apparently codecov is having connection issues. Anyone with rights willing to bounce the failed build tests?

Copy link
Copy Markdown
Member

@tgamblin tgamblin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely cool, but I have some reservations -- see below.

# _sp_module_prefix is set by spack --print-sh-vars
if test "${need_module}" = "yes" ; then
module() {
eval `${MODULE_PREFIX}/Modules/bin/modulecmd ${SHELL:=bash} $*`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure we can rely on this. See @becker33's #8570.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a fair comment. It only works with environment-modules, and even then I'm not sure how externally stable it is. That said, it's almost verbatim from the original.

fi
if _spack_fn_exists module ; then
eval orig_"$(declare -f module)"
function module () {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above w.r.t. #8570 -- I think it has to call module, or at least consider that modulecmd may not be findable.

The other worry I have here is that this won't work for users who load modules after they log in. I've seen users at LC manually source the module initialization scripts long after startup. Now they need to know to source Spack init after module init too. That doesn't seem reliable. The current implementation just ensures that MODULEPATH is set, so modules will pick up Spack stuff even if loaded later.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a fair concern. The main goal is just to make it so that the initial load doesn't have to wait. Really, having a supported mechanism for outputting a set of environment variables that avoids having to call into python (with the agreement that the info may be stale) might be a better way to do this. The mechanism to print out the contents is already there, maybe adding a way to tell this script not to re-compute paths would be more palatable?

orig_module "$@"
}
function ml () {
module "$@"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this yours or is this an alias that ships with modules? Wouldn't the module definition handle it already?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an alias that is part of the module profile file. That probably shouldn't stay in, but since the original was providing a bespoke module command, when bootstrapping modules by this script, I added this one for consistency.

@alalazo
Copy link
Copy Markdown
Member

alalazo commented Feb 12, 2019

Relates to #7591

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants