Skip to content

Add in-memory caching for directory reads#613

Open
zapdos26 wants to merge 3 commits intoenvmodules:mainfrom
zapdos26:fix/readdir-memcache
Open

Add in-memory caching for directory reads#613
zapdos26 wants to merge 3 commits intoenvmodules:mainfrom
zapdos26:fix/readdir-memcache

Conversation

@zapdos26
Copy link

This pull request introduces an in-memory cache for directory reads in the getFilesInDirectory function to optimize performance by avoiding redundant reads during a single module command invocation. Additionally, a new test has been added to verify that the cache returns consistent results for repeated queries.

Caching improvements:

  • Added an in-memory cache to the getFilesInDirectory function in tcl/main.tcl.in, wrapping the original implementation and storing results for repeated directory queries within a single invocation.

Testing enhancements:

  • Introduced a new test in testsuite/modules.90-avail/025-memcache.exp to confirm that consecutive avail queries on the same module path return consistent results, validating the effectiveness of the cache.

Wrap getFilesInDirectory (C extension or Tcl fallback) with an
in-memory cache keyed by directory path and fetch_dotversion flag.

The cache lives for the duration of a single modulecmd process,
avoiding redundant directory reads when the same directory is
accessed multiple times during module resolution or overlapping
search traversals. This reduces NFS round-trips on systems with
thousands of modulefiles across deep directory structures.

Signed-off-by: zapdos26 <zapdoskid@gmail.com>
Verify that the in-memory getFilesInDirectory cache returns correct
results on repeated queries within a single invocation. Tests
exercise cache population and cache hit paths.

Signed-off-by: zapdos26 <zapdoskid@gmail.com>
@zapdos26 zapdos26 changed the title Fix/readdir memcache Add in-memory chacing for directory reads Feb 17, 2026
@zapdos26 zapdos26 changed the title Add in-memory chacing for directory reads Add in-memory caching for directory reads Feb 17, 2026
…t env(TESTSUITE_MCOOKIE_CHECK) evalhide

Signed-off-by: zapdos26 <zapdoskid@gmail.com>
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.

1 participant