-
-
Notifications
You must be signed in to change notification settings - Fork 491
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
Improve startuptime by postponing the creation of argspecs of cached functions/methods #15038
Comments
comment:1
Attachment: trac15038-postpone_argspec_of_cached_functions.patch.gz It seems to me that I observe a decrease of startup time of 4 or 5 percent with my patch, but I'd like to know whether the patchbots confirm this. |
comment:2
Startup time is not everything, I think we should also test that there is no big regression in calling a cached method. With the patch:
Without the patch:
I think this is fine. So, if the startup time would really improve by a couple percent, it would be a good progress. |
comment:3
Unfortunately, the patchbot does not confirm what I saw when I've run |
comment:4
Hey Simon, Here are my timings with patch (same setup):
and without:
So I don't see any (statically) significant speed regression, nor do I expect a couple of simple C-level if statements to slow anything down. I also get a modest startup-time improvement of about 5%, so I'm happy with this patch. Best, Travis |
Reviewer: Travis Scrimshaw |
Merged: sage-5.12.beta3 |
Currently, if a cached method or function is created, an instance of
sage.misc.function_mangling.ArgumentFixer
is created as well. But this is only needed when the cached function/method is actually called.With this patch, the
ArgumentFixer
is either created when it is needed to normalise arguments (i.e., when the function is called), or when aCachedMethodCaller
is bound to an instance. The latter is because differentCachedMethodCaller
s bound to different instances share theArgumentFixer
with theCachedMethod
that is bound to the class of the instances. Hence, it is reasonable to avoid creating the sameArgumentFixer
repeatedly.Without the patch, more than 500
ArgumentFixer
s are created during startup of Sage. This is expensive, because one needs to determine the argspec of the cached functions/methods (this may even involve reading source code!!). With the patch, only 6ArgumentFixer
s are created.CC: @nbruin @vbraun @robertwb
Component: performance
Keywords: cached method, argspec, introspection, startup
Author: Simon King
Reviewer: Travis Scrimshaw
Merged: sage-5.12.beta3
Issue created by migration from https://trac.sagemath.org/ticket/15038
The text was updated successfully, but these errors were encountered: