-
Notifications
You must be signed in to change notification settings - Fork 46
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
Closing Z3 context consumes a lot of time #236
Comments
The
Can you use a Java profiler and locate the exact section where the time is spent? |
I'm also working on Dartagnan and I noticed that the call to |
In my case is also
but I assume |
Small updated ... I manage to make the solvers work also in Linux. |
The symptoms are very vague and hard to reproduce without further information.
|
One of our benchmarks has around 20 seconds solving time and takes at least 4 minutes to close. That example has:
This exactly mimics the way we used Z3 before. We replaced all calls to Z3 with the respective calls to JavaSMT. As far as I can tell, this problem seems to appear in all our medium-sized and larger benchmarks. |
Would it help if we generate the SMT2 file out of the encoding? |
Maybe it might be helpful. |
Btw ... When googling if people have experienced this directly when using Z3, I found this which mentions @PhilippWendler ... Maybe he has some idea |
I will also work on tests for #237. Within a few minutes, I found performance issues in Princess and SMTInterpol. :-) |
@cheshire was JavaSMT maintainer back then. The reason why he mentioned me in this comment was that two days before I wrote the following to him via mail:
However, @cheshire replied that at the time I wrote this, the Z3 version in JavaSMT did not even include the two commits from Z3Prover/z3#679 yet. (On 2016-07-12, 08c4f48 upgraded to z3-4.4.1-1558-gf96cfea and only on 2016-07-22 f3f8d56 upgraded to z3-4.4.1-1624-g82d0310. The commits in question are z3-4.4.1-1569-gb080e3a21 and z3-4.4.1-1570-g4720d578a.) So my problems back then might not have been related to Z3Prover/z3#679, but of course it could be that the current problems are. Regarding the discussion Z3Prover/z3#679 I don't know more than that. There have been quite a few other changes related to closing and cleanup back then (I know Z3Prover/z3#245, Z3Prover/z3#648, Z3Prover/z3#661), but these are more on the Java side and should not influence Some ideas:
|
Here is the
At the java level, the code looks like
As @ThomasHaas mentioned, the first check in this example is SAT. The |
I did not get it ... are you talking about the Z3 API? what do you mean by "dumping such a query"? In our version of the code where we use Z3 API instead of JavaSMT (the code is identical modulo method renaming, e.g. |
I am talking about the replay log of Z3, and suggest to create such a log for a query with a costly close. With JavaSMT the option
Then it seems trying to recreate the problem like I suggested as a C problem is unlikely to succeed. Idea: use ltrace to dump all C API calls to Z3 from your program, once using the direct Z3 API and once using JavaSMT, and compare this. I guess there has to be a difference in the API usage earlier that leads to the later difference. |
If I understood correctly, this would create a file that I can feed as an input to the Is there a way a way to set this options directly at the java level (we are not yet using configuration file)?
|
Exactly. |
Are the entries as follow?
Do I need somehow to specify the log file name or where to create it? |
The name would be Btw.: All configuration options of JavaSMT are documented in a text file named |
Wow ... by taking a look to I set this option to |
Interesting. What this option does is to couple Java's garbage collection and Z3's reference counting: After a For your case, the main effect is probably that our Apart from this, the effects of enabling phantom references are:
So if you have an application that fits the usage pattern of the last item, it should be worth it. If not, e.g., because you just have short-lived contexts or because you keep references to basically all formulas anyway forever, then probably not (but you could benchmark it). This is why it is not enabled by default. |
Note that it seems to me that since Z3Prover/z3#648, Z3's own Java API always uses phantom references and also iterates over all created objects and cleans them up manually before calling However, I would still say that |
Solved. |
I'm trying to replace the use of z3 API with JavaSMT in the
dartagnan
tool. Most of the integration is looking good so far but we just noticed some performance problems when usingSolvers.Z3
as the underlying solver inMacOS
.Calling
SolverContext.close()
is extremely slow for some benchmarks, e.g. for a formula where the solving time is around 9 secs, closing the context takes more than 20 secs.This is surprisingly since the concrete implementation of
close()
inZ3SolverContext
seems to callNative.delContext(context)
which is the same the Java bindings for z3 does.Any idea what the reason might be? Any further information I could provide to find the root of this?
The text was updated successfully, but these errors were encountered: