Reduce frequency of timeout checks by 10+ times #3628
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In some games (meat boy)
instant::now()
was taking 10+% of tick time (and that wasn't even the full recorded overhead of the check), so this still needed to be tuned down. In the future, if other actions become faster, this might need to be tuned down even more.Why "10+ times"? Because if a small function runs between 200 and 2000 actions, its # of checks will drop to 0.
That raises a side question: should
actions_since_timeout_check
be stored in Context instead of Activation? In practice, I feel like this isn't an issue, as even if an inifinite loop span across a deep call stack, the outermost frame with the loop will amass 2000 actions at some point, right? So the current approach of storing in Activation might even be better as it decreases the frequency of checks without making them weaker.Alternatively, just put it in Context and bump the number even more.