-
Notifications
You must be signed in to change notification settings - Fork 33
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
Use Dolmen in the JS worker #1249
Conversation
This PR removes the dependency of the Javascript worker to the legacy frontend in order to remove it completely. In order to avoid code duplication as it was done with the legacy frontend, we reuse the `Solving_loop` module in the worker. This requires some modifications: - Add a new argument to the main function of `Solving_loop` to give different kind of sources instead of reading the file at the path `Options.get_file ()`. The worker used a raw string as input. I reused the type `Dolmen_loop.State.source`. - Add a new argument to the main function of `Solving_loop` to pass the selector hook to the constructor of the environment of the SAT solver. This hook is not used by the worker to select instantiations but just to record them. I have no strong opinion to preserve this feature but I try to keep all the feature of the Javascript worker. - Remove the unused `sat_env` argument of the constructor `init_env` in `Frontend`. This removal is mostly motivated by the fact the semantic of `init_env = Some env` + `selector_inst = Some f` is not clear at all. - Monomophize the `status` type in `Frontend`. This status is only used for printting purposes but we kept the SAT environment in some of its constructors. Unfortunately, the type of the SAT can change at the very beginning of the main function of `Solving_loop`, which means it is not easy to add a new argument for the `hook_status`. This hook is required to print the result of AE in the worker.
cf1ecbf
to
3a3a8b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good to me --- I think we can simplify handling of input files with Gbury/dolmen#201 and maybe get rid of Compat.In_channel.input_all
entirely. If you have time to look into it it'd be great, but it's not important and I'm OK merging as is as well.
src/bin/common/solving_loop.ml
Outdated
| `Stdin when is_incremental -> | ||
set_output_format ".smt2"; | ||
`Stdin | ||
| `Stdin -> | ||
`Raw (filename, Compat.In_channel.input_all stdin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is no longer necessary since Gbury/dolmen#201 and can be replaced with:
| `Stdin when is_incremental -> | |
set_output_format ".smt2"; | |
`Stdin | |
| `Stdin -> | |
`Raw (filename, Compat.In_channel.input_all stdin) | |
| `Stdin -> `Stdin |
(And the definition for is_incremental
removed)
src/bin/common/solving_loop.ml
Outdated
let cin = open_in path in | ||
let content = Compat.In_channel.input_all cin in | ||
close_in cin; | ||
`Raw (filename, content) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: not sure why we had this, I think this can just be `File path
(provided that we call set_output_format
first)?
let res = Worker_interface.init_results () in | ||
let msg = Fmt.str "Unknown error: %s" (Printexc.to_string exn) in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this is not sufficient to catch some errors because the worker is running into Lwt monad and the backtrace is sometimes lost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is still better for the ones we do catch — I'll take an improvement over what we had before even if it is not perfect!
| Sat of Commands.sat_tdecl | ||
| Unknown of Commands.sat_tdecl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am slightly surprised that we were never using these environments, but if that is the case, there is no point to keep them anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me too. Our API is such an onion with too many layers, we didn't notice it before.
src/lib/util/compat.ml
Outdated
@@ -153,3 +153,99 @@ module Type = struct | |||
match A.Id with B.Id -> Some Equal | _ -> None | |||
end | |||
end | |||
|
|||
module In_channel = struct | |||
open In_channel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes unfortunately that one is not going to work since the module itself was added in 4.14; bummer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outch!
Unfortunately, we still need |
I think for the zip format we use |
We do not need `In_channel.input_all` too ;)
This PR removes the dependency of the Javascript worker to the legacy
frontend in order to remove it completely. In order to avoid code
duplication as it was done with the legacy frontend, we reuse the
Solving_loop
module in the worker. This requires some modifications:Add a new argument to the main function of
Solving_loop
to givedifferent kind of sources instead of reading the file at the path
Options.get_file ()
. The worker used a raw string as input. I reusedthe type
Dolmen_loop.State.source
.Add a new argument to the main function of
Solving_loop
to pass theselector hook to the constructor of the environment of the SAT solver.
This hook is not used by the worker to select instantiations but just to
record them. I have no strong opinion to preserve this feature but I
try to keep all the feature of the Javascript worker.
Remove the unused
sat_env
argument of the constructorinit_env
inFrontend
. This removal is mostly motivated by the fact the semanticof
init_env = Some env
+selector_inst = Some f
is not clear atall.
Monomophize the
status
type inFrontend
. This status is only usedfor printting purposes but we kept the SAT environment in some of its
constructors. Unfortunately, the type of the SAT can change at the
very beginning of the main function of
Solving_loop
, which means itis not easy to add a new argument for the
hook_status
. This hook isrequired to print the result of AE in the worker.