主权项 |
1. A computer-implemented method of performing an optimization technique of memoization wherein a program's performance is improved by caching results of one or more function calls so that when the program is executing, the cached results may be returned for the one or more function calls without having to re-execute them, the computer-implemented method being performed by at least one processor executing computer executable instructions for the computer-implemented method, and the computer-implemented method comprising:
performing a static code analysis of the program which identifies for one or more functions of the program whether a function has a side effect, and if not, classifying the function as pure, and if the function has a side effect, classifying the function as impure; for each function classified as pure, determining whether the pure function is associated with a computational cost that meets or exceeds a selected threshold value that represents a minimum computation cost or overhead by which optimization would be improved by memoization of the pure function, and if the pure function meets or exceeds the threshold value, adding the pure function to a memoization list; for each function classified as impure, executing the impure function in an instrumented execution environment with a load generator in order to perform a further analysis to determine if the impure function meets additional criteria which comprises:
determining whether the impure function is associated with a computational cost that meets or exceeds the selected threshold value, and if not skipping the impure function;evaluating whether the impure function behaves consistently and predictably while executing under a load imposed by the load generator, and if not skipping the impure function; andlooking up at least one side effect of the impure function in a database used to classify side effects on either a white list representing side effect known to be innocuous or de minimus or a black list representing side effects for which memoization is improper, and if the at least one side effect is on the black list, skipping the impure function; if the additional criteria is met, adding the impure function to the memoization list and storing the memoization list in a configuration database to facilitate retrieval of cached results of the impure function added to the memoization list; and subsequently using the stored memoization list to facilitate return of the cached results for one or more functions stored on the memoization list so that the cached results are provided without having to re-execute the one or more functions. |