-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cache result of 'module avail' calls #1742
Conversation
@ocaisa can you give this a try? should make quite a bit of difference for your use case... |
EasyBuild framework unit test suite PASSed (see https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/2973/console for more details). This pull request is now ready for review/testing. Please try and find someone who can tackle this; contact @boegel if you're not sure what to do. |
EasyBuild framework unit test suite PASSed (see https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/2974/console for more details). This pull request is now ready for review/testing. Please try and find someone who can tackle this; contact @boegel if you're not sure what to do. |
@wpoely86 thoughts? |
Just took it for a test drive:
Which is compared to 4.5m before any caching and 2.5m with |
EasyBuild framework unit test suite FAILed. See https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/2975/console for more details. Please fix the reported issues by pushing additional commits to the branch corresponding with this pull request; contact @boegel if you're not sure what to do. |
EasyBuild framework unit test suite FAILed. See https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/2976/console for more details. Please fix the reported issues by pushing additional commits to the branch corresponding with this pull request; contact @boegel if you're not sure what to do. |
@@ -115,9 +115,31 @@ | |||
_log = fancylogger.getLogger('modules', fname=False) | |||
|
|||
|
|||
MODULE_AVAIL_CACHE = {} | |||
MODULE_SHOW_CACHE = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would help it you would put a comment about the format of this cache
ans = nub([mod['mod_name'] for mod in mods]) | ||
# cache 'avail' calls without an argument, since these are particularly expensive... | ||
key = ('MODULEPATH=%s' % os.environ.get('MODULEPATH', ''), ';'.join(extra_args)) | ||
if not mod_name and key in MODULE_AVAIL_CACHE: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we only cache a full ml av
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that's also by far the most expensive and common call
also caching argument-less avail calls would need more care w.r.t. invalidating the cache, etc.
Now 10X on the original 4m30...that's an order of magnitude :)
|
@@ -490,7 +526,16 @@ def show(self, mod_name): | |||
""" | |||
Run 'module show' for the specified module. | |||
""" | |||
return self.run_module('show', mod_name, return_output=True) | |||
key = ('MODULEPATH=%s' % os.environ.get('MODULEPATH', ''), mod_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you do this in several place, why not put it in a function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very valid remark, thanks
EasyBuild framework unit test suite FAILed. See https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/2977/console for more details. Please fix the reported issues by pushing additional commits to the branch corresponding with this pull request; contact @boegel if you're not sure what to do. |
paths_in_key = '='.join(key[0].split('=')[1:]).split(os.pathsep) | ||
_log.debug("Paths for 'module %s' key '%s': %s", subcmd, key, paths_in_key) | ||
for path_in_key in paths_in_key: | ||
if os.path.samefile(path, path_in_key): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, may need to be more careful here, samefile
throws an error if either of these paths don't exist
Just got an error when using this for an installation:
|
EasyBuild framework unit test suite FAILed. See https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/2980/console for more details. Please fix the reported issues by pushing additional commits to the branch corresponding with this pull request; contact @boegel if you're not sure what to do. |
…to invalidate module caches with (i.e. take into account possible .lua extension)
@ocaisa the error you ran into should be fixed, please verify? |
EasyBuild framework unit test suite PASSed (see https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/2981/console for more details). This pull request is now ready for review/testing. Please try and find someone who can tackle this; contact @boegel if you're not sure what to do. |
EasyBuild framework unit test suite PASSed (see https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/2982/console for more details). This pull request is now ready for review/testing. Please try and find someone who can tackle this; contact @boegel if you're not sure what to do. |
@boegel Error is fixed |
Just tested Perl: instead of 4-5 hours, it now builds in 37m 😃 |
👍 |
EasyBuild framework unit test suite PASSed (see https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/2983/console for more details). This pull request is now ready for review/testing. Please try and find someone who can tackle this; contact @boegel if you're not sure what to do. |
partialfix for #1739, implements caching formodule avail
(without any arguments) andshow