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

Performance problem with Solver.translate() #5653

Closed
CanCebeci opened this issue Nov 5, 2021 · 4 comments
Closed

Performance problem with Solver.translate() #5653

CanCebeci opened this issue Nov 5, 2021 · 4 comments

Comments

@CanCebeci
Copy link

I've been experimenting with incrementalism in the context of symbolic execution using z3 (Python API). When forking a state, I use Solver.translate() to clone the solver instead of creating a new solver instance and copying all the constraints, as suggested in #556. I've surprisingly observed that Solver.translate() is much slower than the latter approach. Could you help me understand why that is?

@NikolajBjorner
Copy link
Contributor

Solver.translate does not copy the original constraints, it copies constraints after pre-processing. It also copies learned lemmas with high glue levels and it copies model reconstruction instructions. These three elements can each contribute to overhead beyond the original set of constraints but they should not outright lead to drastic slow-downs.
The main way the reconstruction stack can grow to something larger than the original constraints if the solver applies variants of blocked clause elimination or variable elimination that involves several clauses.
The mundane reasons for slowdowns are typically performance bugs (code bugs) that apply naive algorithms for copying state. It is easier to get an idea of what is going on with something concrete.

@NikolajBjorner
Copy link
Contributor

Do you have any repro or were you able to gain insights based on the above comment?

@CanCebeci
Copy link
Author

CanCebeci commented Nov 11, 2021

Sorry for the delayed reply. You can find here 12 instances I've come upon where translate is significantly slower.

Unzipping and running reproduce_clone.py should suffice. Hope this helps.

NikolajBjorner added a commit that referenced this issue Nov 11, 2021
fix performance bottleneck in static features
@NikolajBjorner
Copy link
Contributor

Thanks, the repro is useful. It uses the files in an essential way. I pushed an update that addresses a main perf bottleneck.

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

No branches or pull requests

2 participants