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

TD3: optimize destabilization by aborting transfer function when unchanged #364

Merged
merged 38 commits into from
Nov 8, 2021

Conversation

sim642
Copy link
Member

@sim642 sim642 commented Sep 29, 2021

This is an attempt to optimize destabilization by making the resolving reluctant (not the destabilization).

The problem and intuition is that when something gets destabilized, the propagating changes might not change everything all the way to the end of the program (or a called variable). At some point the result might be unchanged, but the outer solve call will still evaluate the transfer function once more to observe that each layer going up is unchanged. If all the inputs to the transfer function (computation tree) are unchanged, then this is unnecessary computation (the result will be the same as before).

The trick is the following: if all dependencies (in destab_dep) of a variable are unchanged, then the last eval will raise AbortEq, which will be caught outside the transfer function. This is necessary because if something has changed, then the only way to know the new dependencies (which may be different) is to evaluate the black box of the transfer function.
The functions solve, simple_solve and eval are changed to return a boolean indicating whether a change occurred or not.

This is still not sufficient to behave correctly because a destabilized variable might be solved (and thus made stable again) before another influenced variable of it is solved again. Thus the changed value might incorrectly appear as unchanged.

To combat this problem, a front (in destab_front) of destabilized variables is tracked. Initially it consists of the first layer of destablized variables (the rest are still destabilized recursively, but not added to the front). When a variable in the front changes (during a later solve), it pushes the front forward to its influences variables (before destabilization, in destab_infl). If however it doesn't change, then the front dies out there and all destabilized variables after the died front never have to be reevaluated.

TODO

  • Add back support for space variant. (Can be enabled without abort, fails with abort.)
  • Benchmark.
  • Optimize FromSpec to first getl all values for Cfg.prev before executing any of the transfer functions. This could provide earlier abort opportunities.
  • Figure out how to combine with Incremental TD3: restart destabilized side-effected variables #363 to merge to interactive.

@sim642 sim642 added feature performance Analysis time, memory usage labels Sep 29, 2021
@sim642 sim642 self-assigned this Oct 14, 2021
@sim642
Copy link
Member Author

sim642 commented Oct 19, 2021

Here's a performance comparison of no-abort (x-axis) vs abort (y-axis, without abort-verify) on sv-benchmarks SoftwareSystems+ConcurrencySafety with 60s timeout:
image

So almost always this provides a performance boost of up to 1.5 times. The few outliars, last I checked, are those weird cases where we nondeterministically have ERROR (verify).

After the final fixes at this point, running with abort-verify confirms no illegal abortions (pun intended), but similar benchmarks also show that it's not worth keeping enabled all the time because it defeats the gain by abort.

@sim642
Copy link
Member Author

sim642 commented Oct 22, 2021

I tried optimizing FromSpec to get all CFG predecessor values before executing any of their transfer functions (which matters at join points), but it didn't seem to make a noticeable difference.

Interestingly it introduced 6 outliars where a stack overflow turned into a simple timeout:
image
So somehow this reordering of things in the right-hand sides changes the solving enough to not recurse so deep. I'm not sure how exactly though.

@sim642 sim642 changed the base branch from master to interactive November 8, 2021 11:59
@sim642 sim642 marked this pull request as ready for review November 8, 2021 12:01
@sim642
Copy link
Member Author

sim642 commented Nov 8, 2021

Merging into the branch interactive for better experimentation.

@sim642 sim642 merged commit 8cb50d4 into interactive Nov 8, 2021
@sim642 sim642 deleted the td3-solve-tf-abort branch November 8, 2021 12:02
@sim642 sim642 mentioned this pull request Nov 8, 2021
5 tasks
sim642 added a commit that referenced this pull request May 13, 2022
This reverts commit 8cb50d4, reversing
changes made to b72dfe4.
sim642 added a commit that referenced this pull request May 13, 2022
This reverts commit 8cb50d4, reversing
changes made to b72dfe4.

Includes reverting of additional fixes later made to abort on the interactive branch.
@sim642 sim642 mentioned this pull request May 19, 2022
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature performance Analysis time, memory usage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant