Skip to content

Add ignore_cache_subcmds configuration option - #688

Merged
xdelaruelle merged 4 commits into
envmodules:mainfrom
xdelaruelle:issue563
Aug 23, 2026
Merged

Add ignore_cache_subcmds configuration option#688
xdelaruelle merged 4 commits into
envmodules:mainfrom
xdelaruelle:issue563

Conversation

@xdelaruelle

Copy link
Copy Markdown
Collaborator

A module cache file aggregates the content of all the modulercs and modulefiles found in a modulepath. When a module search occurs, this whole file is evaluated even if the search targets specific modules. On setups with a very large number of modulefiles, resulting in cache files of several megabytes, evaluating the whole cache file may take longer than walking through the modulepath directory to find the few requested modules, as reported in the mailing-list discussion linked in #563.

This change introduces the ignore_cache_subcmds configuration option that defines a list of module sub-commands on which module cache files are ignored. When one of these sub-commands is run, modulepath directories are walked through to search modules instead of relying on their cache file. For instance to keep cache benefit on listing sub-commands but avoid its penalty on targeted ones:

module config ignore_cache_subcmds load:try-load:load-any

The option is compared against the resolved top-level sub-command name, obtained with the new topCommandName helper procedure: sub-command name aliases (like add for load) resolve to their target sub-command, and the ml command used without a sub-command name translates to the underlying load or unload sub-command it is currently processing. When the configuration option is changed with the config sub-command, it sets the MODULES_IGNORE_CACHE_SUBCMDS environment variable.

Fixes #563

Module cache file aggregates the content of all the modulercs and
modulefiles found in a modulepath. When a module search occurs, this
whole file is evaluated even if the search targets specific modules.
On setups with a very large number of modulefiles, resulting in cache
files of several megabytes, evaluating the whole cache file may take
longer than walking through the modulepath directory to find the few
requested modules.

Add the ignore_cache_subcmds configuration option that defines a
list of module sub-commands on which module cache files are ignored.
When one of these sub-commands is run, modulepath directories are
walked through to search modules instead of relying on their cache
file. Option is compared against the resolved top-level sub-command
name, obtained with the new topCommandName helper procedure, so
sub-command name aliases (like add for load) resolve to their target
sub-command and cache is also ignored for the searches that the
evaluated modulefiles trigger. The ml command used without a
sub-command name translates to the underlying load or unload
sub-command it is currently processing.

When configuration is modified it sets the
MODULES_IGNORE_CACHE_SUBCMDS environment variable.

Fixes envmodules#563

Assisted-by: Claude:claude-fable-5
Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
Add ignore_cache_subcmds to the configuration option names proposed
by the bash, fish, tcsh and zsh completion scripts for the config
sub-command.

Assisted-by: Claude:claude-fable-5
Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
Describe the ignore_cache_subcmds configuration option and its
associated MODULES_IGNORE_CACHE_SUBCMDS environment variable in the
module man page, configuration option table, release notes, migration
guide and module cache design notes.

Assisted-by: Claude:claude-fable-5
Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
Clear MODULES_IGNORE_CACHE_SUBCMDS from test environment, add the
new option to the config sub-command checks and craft specific tests
verifying cache files are only ignored on the sub-commands listed in
option value. Sub-command name alias resolution (add) and ml frontend
translation to underlying load sub-command are also covered. These
tests fail without the ignore_cache_subcmds option code change.

Assisted-by: Claude:claude-fable-5
Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
@xdelaruelle
xdelaruelle merged commit 217ff30 into envmodules:main Aug 23, 2026
20 checks passed
@xdelaruelle
xdelaruelle deleted the issue563 branch August 23, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ignoring cache for a given list of sub-command

1 participant