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 lastCompute #398

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Implement lastCompute #398

wants to merge 3 commits into from

Conversation

hatmatty
Copy link

@hatmatty hatmatty commented Dec 17, 2024

There is currently an issue with the evaluate function.

In evaluate.luau look at the section of the code that decides whether a recompute is needed. Assume dependency.lastChange > target.lastChange is true for one of the dependencies.
Then when the computation is complete assume the new value is the same, so "targetMeaningfullyChanged" is false and target.lastChange does not update.

Then dependency.lastChange > target.lastChange will remain true and the target will keep updating unnecessarily when it has already been computed with the new value of the dependency.

A fix to this would be to introduce another property, lastCompute, which tracks the last time a stateobject was updated.

print("AQUI!")
-- expect(#scope).to.equal(2)
-- doCleanup(scope)
-- expect(counter).to.equal(3)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this section was replaced with a print statement?
Or was it just left over from debugging?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah that's a mistake. Good catch

@hatmatty
Copy link
Author

hatmatty commented Dec 18, 2024

an alternate way to do this without modifying a lot of the files would be to do

if target.lastCompute then
	if dependency.lastChange > target.lastCompute then
		needsComputation = true
	end
else
	if dependency.lastChange > target.lastChange then
		needsComputation = true
	end
end

in evaluate.luau, and then set lastCompute in the "if needsComputation" block.

@bytejon
Copy link

bytejon commented Jan 5, 2025

Can you provide an example (with code) to highlight this issue happening with the current behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants