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

Introduce backwards compatible infrastructure for parallelism #1708

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

arkocal
Copy link
Contributor

@arkocal arkocal commented Mar 11, 2025

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.

arkocal and others added 7 commits March 11, 2025 10:16
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
@arkocal arkocal force-pushed the parallelism_backwards_compat_1 branch from 522315f to 80cac2a Compare March 11, 2025 09:36
@arkocal arkocal force-pushed the parallelism_backwards_compat_1 branch from 80cac2a to 3f7d226 Compare March 11, 2025 09:38
@arkocal arkocal added the parallel Parallel Goblint label Mar 11, 2025
@arkocal
Copy link
Contributor Author

arkocal commented Mar 11, 2025

Turns out introducing domain_shims breaks GobView. The application than outputs

Uncaught TypeError: runtime.caml_thread_self is not a function

on the console and hangs indefinitely.

@sim642 sim642 self-requested a review March 11, 2025 12:52
@michael-schwarz
Copy link
Member

Turns out introducing domain_shims breaks GobView. The application than outputs

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?

@michael-schwarz
Copy link
Member

I guess we either need to turn the gobview job into an unlocked one, or provide a different lockfile for the gobview job somehow?

Comment on lines +2521 to +2525
"parallel_domains" :{
"title": "solvers.td3.parallel_domains",
"description": "Maximal number of Domains that the solver can use in parallel. Only applies, when a solver of the 'td_parallel_*' family is used.",
"type": "integer",
"default": 2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the existing jobs option would also work for this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth having the concurrency settings for non-core stuff (g2html, preprocessing) separate from the solver concurrency, especially when comparing runtimes.

Comment on lines +200 to +203
let pp_print_option ?(none = fun _ () -> ()) pp_v ppf = function
| None -> none ppf ()
| Some v -> pp_v ppf v
in
Copy link
Member

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?

Comment on lines -24 to +25
let recursive_int = lazy (
let recursive_int = DomainsafeLazy.from_fun (fun () ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is DomainsafeLazy only used here? There are other top-level lazy values like

  • Offset.Index.Exp.all
  • Cilfacade.any_index_exp
  • LibraryFunctions.intmax_t

There's also ResettableLazy which is used all over. Are all of those safe then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Also what about LazyEval? Are we fine with force being called concurrently there?

let add_ref: (Token.t -> unit) ref = ref (fun _ ->
let add_ref: (Token.t -> unit) Domain.DLS.key = Domain.DLS.new_key (fun () _ ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar question here: we have a lot of top-level refs around, but only this one is made domain-local. Are all others fine then?

Comment on lines +18 to +19
let enabled_dls = Domain.DLS.new_key (fun () -> false)
let options_dls = Domain.DLS.new_key (fun () -> dummy_options)
Copy link
Member

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.

@@ -38,9 +39,13 @@ let traceTag (sys : string) : Pretty.doc =
let rec ind (i : int) : string = if (i <= 0) then "" else " " ^ (ind (i-1)) in
(text ((ind !indent_level) ^ "%%% " ^ sys ^ ": "))

let trace_mutex = GobMutex.create ()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracing isn't the only output from Goblint. Why don't others (like Logs and Messages) also need locks?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those should happen at the end in postprocessing, which is not concurrent afaik.

@sim642 sim642 added the setup Dependencies, CI, releasing label Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parallel Parallel Goblint setup Dependencies, CI, releasing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants