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

CN: Race solvers #770

Open
dc-mak opened this issue Dec 17, 2024 · 7 comments
Open

CN: Race solvers #770

dc-mak opened this issue Dec 17, 2024 · 7 comments

Comments

@dc-mak
Copy link
Contributor

dc-mak commented Dec 17, 2024

There are a few axes on which to race:

  • Incremental vs non-incremental solver
  • CVC5 vs Z3
  • (Potentially) derived constraints vs minimal constraints

This seems like a good fit: https://github.com/ocaml-multicore/eio?tab=readme-ov-file#racing, although it would commit us to OCaml 5 (but avoid wrapping all the solver code in a monad).

Note: racing an incremental solver with other ones will naturally bring up some concurrency query-to-query, because the process will be the same, so cancelling queries may need to lock and clean up appropriately.

There is also an inherent racy-ness that the solver might return an answer after cancel is sent, in which case the incremental solver will be accidentally closed would need to be restarted with the correct context before the next query.

@bcpierce00
Copy link
Collaborator

Is it bad to commit to OCaml 5 at this point?

@PeterSewell
Copy link
Contributor

PeterSewell commented Dec 17, 2024 via email

@cp526
Copy link
Collaborator

cp526 commented Dec 17, 2024

Some linux distributions will have OCaml versions older than that pre-installed, so dependency on a newer OCaml will require an extra installation step for those users, but I don't think that should stop us if there's a good reason (such as the above).

@podhrmic
Copy link
Contributor

FWIW I doubt that any industry partners will be installing OCaml natively, most likely mean of deployment seem to be a Docker image (see GaloisInc/VERSE-Toolchain#48). So as long as it can be installed and packaged in a Docker image, the specific version does not matter.

@yav
Copy link
Collaborator

yav commented Jan 7, 2025

One other interesting consideration is that it is unclear how useful the incremental solvers are in a setup where we race solvers, because the slower solvers would presumably be killed, and have to start over anyway, so they wouldn't really benefit from preserving their internal state.

@PeterSewell
Copy link
Contributor

PeterSewell commented Jan 7, 2025 via email

@cp526
Copy link
Collaborator

cp526 commented Jan 7, 2025

RE incremental solvers: we previously had a setup where we ran an incremental solver with quick timeout (e.g. 0.2s), followed by a non-incremental solver on timeout. The timeout for the incremental solver was a Z3 configuration option rather than an external "kill", meaning we didn't have the problem @yav describes.

I think we'll want to try a setup that

  • has a single incremental solver (either z3 or cvc5, as per command line option), with small timeout, and
  • when that times out, runs non-incremental z3 and cvc5 concurrently.

In James's graphs ( https://rems-project.github.io/cerberus/dev/bench/ ) one can see that the different solvers compare quite differently on different C code examples (let alone individual solver queries, presumably). So being able to race cvc5 and z3 seems like a low-hanging fruit for getting some (much needed) performance improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants