Skip to content
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

Memoization #295

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Memoization #295

wants to merge 3 commits into from

Conversation

flsobral
Copy link
Member

@flsobral flsobral commented Feb 3, 2021

In computing, memoization or memoisation is an optimization technique used primarily to speed up computer programs by storing the results of expensive function calls and returning the cached result when the same inputs occur again.
Wikipedia

  • Hard coded results for fibR inside executeMethod
  • Replace the hard coded results with an actual cache for the method fibR (the method being optimized is still hard coded and we'll only be supporting a single 64-bit argument)
  • Expand implementation to handle methods used in more "real life" examples and perform tests to evaluate the performance we get in more realistic scenarios. One suggestion is for using Math trigonometry methods like sin, cos, tan, asin, acos, atan and atan2, and perform tests drawing circles and stuff.
  • Expand cache to handle a method that returns a 32 bit value (like int)
  • Find out how to detect the return value and use the appropriate detour with XSELECT
  • Add support for arguments with a 32 bit value (like int)
  • Create a new annotation for methods that may be memoized by the VM, which would just set a flag, nothing fancy
  • Change the VM to look for methods flagged for memoization instead of using hard coded method names (please notice we are only actually optimising methods which accept a single argument and both the argument and the return value must be either 32 or 64 bit values)
  • Expand support for methods with N arguments
  • Replace the annotation with automatic detection of memoizable methods

@flsobral flsobral added help wanted Extra attention is needed Performance labels Feb 3, 2021
@flsobral flsobral self-assigned this Feb 3, 2021
please notice I'm testing with a method named fibR which is a
recursive fibonacci with the following signature:
long fibR (long)
macos is not prepared to write to DebugConsole.txt yet
just testing if we can take a detour in method execution
to actually implement memoization.
things are looking promising!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed Performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant