A tutorial on parallel programming in OCaml 5

I do not think it is true that adding asynchronous exception-safety features would be a problem for backwards-compatibility. Current programs not using asynchronous exceptions would continue running just fine because they would not use asynchronous exceptions, and in addition only the part of the program that needs to be interrupted needs to be made exception-safe. You might be thinking about making arbitrary programs ready for asynchronous exceptions, which of course is not realistic and is not a question that we are asking in general.

There are already lots of programs using asynchronous exceptions in OCaml, and it is sometimes not realistic to rewrite them to poll explicitly (as @ejgallego knows well). Once Memprof is available for OCaml 5, my library memprof-limits will provide ways and guidance to interrupt a domain on an arbitrary trigger, including in the presence of resources that need cleaning-up.

The Asynchronous Exceptions in Haskell paper is a nice work but I would not recommend it as a first read nor as a sole reference. There is a non-negligible delta between this paper and the practice of asynchronous exceptions in Haskell, and it omits the experience of other languages that have introduced key exception-safety concepts. I gave a bibliography of important resources on this topic at the end of the guide to program with interrupts and during my presentation at the Ocaml workshop 2021 (video).

2 Likes