reset() vs new Solver #4992
-
I am using the Z3 API for python for satisfiability check given a set of constrains. Suppose I have two set of constrains. Should I have two separate Solver() for the two or should I create one, check it, use the reset() and then add the constrains for the second one and check it! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
That is a complicated topic. BTW there's more than just the solvers; there's also the global caches and symbol tables that Z3 preserves in across solvers. So you need to delete the context and reset the memory ( A new Solver() vs reset? These are very similar. reset() should be slightly faster as some tactics know how to reuse previous memory allocations. The global memory reset has a much more noticeable impact. |
Beta Was this translation helpful? Give feedback.
-
There is overhead setting up a solver. If queries are small, this overhead dominates. Resetting memory from managed interfaces, e.g., Python, Java, C#, Ocaml, |
Beta Was this translation helpful? Give feedback.
There is overhead setting up a solver. If queries are small, this overhead dominates.
Resetting memory from managed interfaces, e.g., Python, Java, C#, Ocaml,
is not practical because of interactions with GC and global objects.
Resetting memory from plain C/C++ remains possible.