Avoid validating every sibling modulefile when resolving an exact version - #658
Merged
Merged
Conversation
xdelaruelle
force-pushed
the
stopmod-optimization
branch
from
July 29, 2026 13:04
ffb8597 to
efa29e3
Compare
…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
force-pushed
the
stopmod-optimization
branch
from
July 29, 2026 14:03
efa29e3 to
d88c73d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
findModules/findModulesFromDirsAndFilesaccept a newstop_modparameter: when resolving an exactname/versionspecification 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 implicitdefault/latestand whether the query itself is that element, without validating every sibling modulefile.load3/load3_cachebenchmark toscript/mb, generating/removing its large sibling-version fixture on the fly.testsuite/modules.20-locate/170-fastdefvers.expcovering 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 failuresscript/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