-
Notifications
You must be signed in to change notification settings - Fork 119
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
SMT backend: performance issues when composing types and mappings #689
Comments
There's an optimisation I've been meaning to implement for a long time which I think will solve this. We need to detect when control flow constructs (if, match, etc) have no side effects and convert them to 'eager' variants, i.e. The problem is all the nested matches in the mapping logic is essentially compiled under the assumption that every branch might have some side effect, which produces a lot of control flow edges we don't need, and the main thing we want to optimise for when generating SMT is a reduction in control flow choices. Sometimes the simplifier can clean this up but when it fails to do so you just get a giant SMT problem. |
Should be improved quite a bit by: #693
|
Awesome, thanks so much! |
There were some issues with the simplification rules which could affect this kind of property, you might want #694 as well just in case. |
Thanks! There still seems to be some unfortunate scaling in runtime: if I change the |
If you post the slower variants I can take a look. I think part of the problem is that each mapping application is guarded by a 'does this mapping apply' guard, and this means some of the matches aren't obviously complete. When this occurs there is a hidden 'match failure' branch which inhibits a bunch of simplifications from occuring. |
This is the >20 minute one. Commenting out the last clause takes about 4 seconds. |
It seems to be spending all its time in Sail, so something is definitely going wrong. With even a single line:
The mapping gets de-sugared to a 'core' functional representation like:
so with additional clauses the control-flow quickly becomes a rat's nest of complexity. I think the way it uses options to represent the intermediate match results is blocking any simplifications so I might try to work on that. |
Part of the issue is we rather pessimistically assume all functions associated with mappings may have an incomplete match. Removing that assumption is currently unsound without a more accurate analysis of the mappings, but when combined with some other small improvements:
|
#704 improves the generation to avoid the blowup in the SMT size caused by complex control flow by introducing intermediate variables for commonly duplicated parts of the path conditions. This isn't as dramatic a speedup for this particular problem as if we had accurate information about mapping completeness, but does still reduce the runtime considerably:
|
The following Sail takes a long time to generate SMT with the latest sail2 branch, and generates a 1MB file when it does. Increasing the number of fields in
MyStruct
seems to cause things to grow exponentially:Sorry about the weird mix of enums, structs, and options: all of them seem to be required to demonstrate the full problem.
The text was updated successfully, but these errors were encountered: