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

Implement unlimited-depth directly-optimal recursion. #83

Draft
wants to merge 32 commits into
base: main
Choose a base branch
from

Conversation

obi1kenobi
Copy link
Owner

@obi1kenobi obi1kenobi commented Oct 2, 2022

Implement a new directly-optimal recursion execution algorithm that can support unlimited-depth recursion, developed in collaboration with @bojanserafimov as part of the HYTRADBOI'22 Jam: https://www.hytradboi.com/jam

Traces show that the new implementation produces the first result in less than half as many steps on even the shallowest of recursion situations. The more steps previously involved in getting the first result from the recursion, the more significant the improvement will be.

After this merges, we'll still need to update the front-end to make the @recurse depth parameter nullable and plumb that change throughout Trustfall to enable unlimited-depth recursion.

@obi1kenobi
Copy link
Owner Author

Unlimited-depth recursion makes adapters even more likely to accidentally trigger the same re-entrancy bug as in #205.

The best way I can see is making a change to the Adapter trait to take &self instead of &mut self, and removing RefCell throughout. If users need mutability, they can use their own RefCell and will need to take care to avoid re-entrancy issues.

@obi1kenobi obi1kenobi added S-experimental Status: ongoing experiment that does not require reviewing and won't be merged in its current state. C-enhancement Category: raise the bar on expectations labels Jun 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: raise the bar on expectations S-experimental Status: ongoing experiment that does not require reviewing and won't be merged in its current state.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant