Will OCaml 5+ multicore be fragile?

This looks a mixing of concerns. As I understand it, ocaml-5 atomics for users are sequentially consistent, just as Go’s appears to be. Ocaml (and as you appear to indicate, Go also) does not offer relaxed memory ordering for its user atomics, nor acquire/release ordering for that matter. What ocaml or Go does in implementing its semantics is something different. If the compiler hackers can’t hack it then we are all doomed.

2 Likes

This is correct. Thanks for the response.

Adding to this point, OCaml does better than Go on programs with data races. With Go, the semantics of programs with data races is undefined, whereas, in OCaml, we have precise semantics for what values can be witnessed. In particular, type and memory safety is preserved for programs with data races. The implication of this guarantee is that, while Go programs with data races can crash, OCaml programs with data races never do. Having undefined semantics on data races will mean that your program may launch missiles, leak secrets, and whatnot.

7 Likes

The Atomic module provided in Ocaml-5 is sequentially consistent, they have to be, otherwise we would have to provide an API for memory barriers.