Skip to content

Avoid validating every sibling modulefile when resolving an exact version - #658

Merged
xdelaruelle merged 1 commit into
envmodules:mainfrom
xdelaruelle:stopmod-optimization
Jul 29, 2026
Merged

Avoid validating every sibling modulefile when resolving an exact version#658
xdelaruelle merged 1 commit into
envmodules:mainfrom
xdelaruelle:stopmod-optimization

Conversation

@xdelaruelle

@xdelaruelle xdelaruelle commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • findModules/findModulesFromDirsAndFiles accept a new stop_mod parameter: when resolving an exact name/version specification in a single-module context (load, display, is-avail, switch, ...), the directory holding it is walked from the dictionary-highest to the dictionary-lowest element, stopping as soon as the first valid, non-hidden element is found. This settles both the directory's true implicit default/latest and whether the query itself is that element, without validating every sibling modulefile.
  • Listing commands (avail, whatis, search, ...) and bare module name resolution are unaffected and keep validating every sibling as before.
  • Adds a load3/load3_cache benchmark to script/mb, generating/removing its large sibling-version fixture on the fly.
  • Adds testsuite/modules.20-locate/170-fastdefvers.exp covering invalid, hidden, and explicit-default-without-explicit-latest siblings, a variant value alongside the query, a hiding rule set in the modulepath's own top-level .modulerc, and a hiding rule targeting a full path modulefile designation.

Closes #561

Test plan

  • make test (full suite): 24905 passed, 0 failures
  • script/mt 20 (locate suite), script/mt 50, script/mt 90, script/mt 92, script/mt 51, script/mt 70: all clean

🤖 Generated with Claude Code

@xdelaruelle
xdelaruelle force-pushed the stopmod-optimization branch from ffb8597 to efa29e3 Compare July 29, 2026 13:04
…sion

findModules/findModulesFromDirsAndFiles now accept a 'stop_mod'
parameter: when set to an exact 'name/version' specification resolved
in a single-module context (load, display, is-avail, switch, ...), the
directory holding it is walked from the dictionary-highest to the
dictionary-lowest element, validating only what is needed to find the
first valid, non hidden element. This settles two things at once: this
is the directory's true implicit default/latest, and stop_mod is that
element or not. Listing commands (avail, whatis, search, ...) and bare
module name resolution are unaffected and keep validating every
sibling as before.

getModules sets 'stop_mod' whenever the query is an exact 'name/version'
specification (no wildcard, no result filtering), optionally with a
variant or an extra match search specifier, as long as the module name
and version part of it still resolves to a single, flat 'name/version'
element.

Add a new load3/load3_cache benchmark test to the mb script,
generating and removing its large sibling-version fixture on the fly.
Measured about 30 ms down to 19 ms (-36%) resolving one of 500 sibling
versions.

Add a new locate testsuite file covering invalid, hidden and
explicit-default-without-explicit-latest siblings, and a variant value
specified alongside the query, with its own fixture modulefiles.
Update two unrelated tests whose expected output depended on the exact
content of the shared modulepath directory used for these new
fixtures.

Closes envmodules#561

Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
@xdelaruelle
xdelaruelle force-pushed the stopmod-optimization branch from efa29e3 to d88c73d Compare July 29, 2026 14:03
@xdelaruelle
xdelaruelle merged commit ffa263d into envmodules:main Jul 29, 2026
19 checks passed
@xdelaruelle
xdelaruelle deleted the stopmod-optimization branch July 29, 2026 15:17
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.

Improve performance when loading a given module with numerous alternative versions or non-modulefile

1 participant