-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 issue when calling Native.delContext() #5414
Comments
file against JavaSMT |
Sorry if the description was not clear, but the issue is actually with While the issue does not happen when using directly Z3's Java API (because as I mentioned it already uses phantom references) I believe others Z3's APIs may suffer this performance problem if the clean up is only done when calling |
If your application maintains lots of references to expressions built using the old context you can't delete the context until these are released. I can't fix bugs in other code bases. |
Maybe I can clear this up. Of course, nobody is asking about other code bases here. What we found out is that This was surprising to us and unintuitive. It would be obvious if Or does your last comment mean that it is actually not allowed to call delete the context if there are still some references? In this case, it would be great if
But more convenient would be if |
The functions in |
We noticed performance issues when calling
Native.delContext()
(it can take up to 4 min for big formulae). This was experienced when switching from Z3 Java API to JavaSMT in our Java application.Using Z3 Java API, closing the context was immediate, we only experienced this through JavaSMT. This looked strange since JavaSMT directly calls
Native.delContext(context)
.The reason is related to the use of phantom references mentioned here #648; Z3's own Java API seems to it use by default, but JavaSTM does not. When configured to use phantom references, JavaSMT calls
decRef()
for all created formula instances before callingdelContext()
. It seems that this manual calling ofdecRef()
and the associated cleanup is more efficient than the cleanup that Z3 does indelContext()
if the formula instances still exist.There is a (probable better) explanation by @PhilippWendler in sosy-lab/java-smt#236.
While this is not a problem when using Z3 throw the Java API, it might cause issues in languages without GC.
The text was updated successfully, but these errors were encountered: