-
Notifications
You must be signed in to change notification settings - Fork 77
Introduce backwards compatible infrastructure for parallelism #1708
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
base: master
Are you sure you want to change the base?
Conversation
In order to maintain backwards compatibility, we need to provide stubs for functionality needed for parallelism when no libraries provide this. Also, to keep possibly diverging parts to a minimum, the utilities for parallelism are kept in a separate module.
This works async in Ocaml4 and truly parallel in OCaml5
fix printing issue by using BatFormat in messages.ml
This is a high level abstraction AND a backward compat. wrapper
Possibly, this could be needed elsewhere, where state is involved
Make stack DLS and initialize for each domain Actually implemented by Felix Krayer
522315f
to
80cac2a
Compare
80cac2a
to
3f7d226
Compare
Turns out introducing domain_shims breaks GobView. The application than outputs
on the console and hangs indefinitely. |
Do you know where this call happens? Is it something we can safely stub to just return unit or somehow avoid these calls when in Gobview mode? |
I guess we either need to turn the gobview job into an unlocked one, or provide a different lockfile for the gobview job somehow? |
let pp_print_option ?(none = fun _ () -> ()) pp_v ppf = function | ||
| None -> none ppf () | ||
| Some v -> pp_v ppf v | ||
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.
What's this about? Isn't it just a copy of what's in Stdlib.Format
?
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.
The module now uses BatFormat
, which does not define the method.
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.
But why BatFormat
? The standard library version from OCaml 5 should be safe: it's been reimplemented to use DLS properly. Batteries as no domains-specific fixes.
src/util/timing/goblint_timing.ml
Outdated
let enabled_dls = Domain.DLS.new_key (fun () -> false) | ||
let options_dls = Domain.DLS.new_key (fun () -> dummy_options) |
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.
Is it necessary for these to be domain-local? These are more like global options than state.
#1550 mentions that maybe only current
needs to be domain-local.
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.
Felix himself has introduced all of them in 62422e9
As far as can see enabled_dls
is rather tracking if it is active in a given moment (set via start
and stop
), and making it a reference makes the solver crash at the end. Options however are global options and can be made into refs.
9e1614d reflects this now.
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.
As far as can see
enabled_dls
is rather tracking if it is active in a given moment (set via start and stop), and making it a reference makes the solver crash at the end.
But we only ever call start
at the very beginning of Goblint and never even call stop
. So I don't understand why there would be any issue. start
also modifies options
and that's fine.
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.
Copilot reviewed 8 out of 25 changed files in this pull request and generated 1 comment.
Files not reviewed (17)
- dune-project: Language not supported
- goblint.opam: Language not supported
- goblint.opam.locked: Language not supported
- src/cdomain/value/cdomains/mutexAttrDomain.ml: Language not supported
- src/cdomain/value/dune: Language not supported
- src/common/util/messages.ml: Language not supported
- src/config/options.schema.json: Language not supported
- src/dune: Language not supported
- src/goblint_lib.ml: Language not supported
- src/lifters/wideningTokenLifter.ml: Language not supported
- src/solver/dune: Language not supported
- src/util/parallel/domainsafeLazy.ml: Language not supported
- src/util/parallel/domainsafeLazy.mli: Language not supported
- src/util/parallel/dune: Language not supported
- src/util/parallel/gobMutex.domainslib.ml: Language not supported
- src/util/parallel/gobMutex.no-domainslib.ml: Language not supported
- src/util/parallel/threadpool.domainslib.ml: Language not supported
Comments suppressed due to low confidence (1)
.github/workflows/unlocked.yml:255
- [nitpick] Consider using consistent capitalization for 'GobView' across workflow configurations to align with the documentation.
gobview:
Looks like the Copilot reviews won't be too useful for us right now since it doesn't want to review .ml files. |
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.
Shouldn't there be a non-parallel implementation here?
(name goblint_parallel) | ||
(public_name goblint.parallel) | ||
(libraries | ||
batteries |
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.
Where is batteries used here?
(select threadpool.ml from | ||
(domainslib -> threadpool.domainslib.ml) | ||
(-> threadpool.no-domainslib.ml) | ||
) |
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.
) | |
) |
@@ -0,0 +1,6 @@ | |||
(** Lazy type which protects against concurrent calls of 'force'. *) |
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.
(** Lazy type which protects against concurrent calls of 'force'. *) | |
(** Lazy type which protects against concurrent calls of {!force}. *) |
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.
If we're taking the mutex implementation from domain-local-await, why not the lazy? https://github.com/ocaml-multicore/domain-local-await?tab=readme-ov-file#example-concurrency-safe-lazy (pending the licence question below)
In particular, that one seems to properly handle exceptions, whereas the one here would royally break: the mutex wouldn't be unlocked even and any future attempts to lock it will block forever.
(* Simple Mutex Implementation using Domain-Local Await (https://github.com/ocaml-multicore/domain-local-await) | ||
Copyright © 2023 Vesa Karvonen | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, | ||
provided that the above copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES | ||
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY | ||
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | ||
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *) |
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.
The big question with this is whether this licence just allows us to swallow the code into MIT-licenced Goblint.
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.
Ther ISC license is compatible in spirit with the MIT license. Maybe we just leave the license notice in this file as is and add at the top in the LICENSE.md that the MIT license applies to all files unless specified otherwise?
I think polluting the opam repo with a package containing only this file for trivial license stuff may be excessive.
(select gobMutex.ml from | ||
(domainslib -> gobMutex.domainslib.ml) | ||
( -> gobMutex.no-domainslib.ml) | ||
) | ||
(select threadpool.ml from | ||
(domainslib -> threadpool.domainslib.ml) | ||
(-> threadpool.no-domainslib.ml) |
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 think it's a good idea to have .mli
files for these as well (not dependent on domainlib presence).
This contains the rather harmless parts. As discussed, all variations of modules have been implemented using
domain_shims
and the select stanza in dune.ppx_optcomp
is not involved anymore.The PR is rather large, but can be reviewed commit-by-commit.