A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/ocaml-multicore/ocaml-multicore/wiki/Concurrency-and-parallelism-design-notes below:

Concurrency and parallelism design notes · ocaml-multicore/ocaml-multicore Wiki · GitHub

Concurrency and parallelism

There are two important types of computation that multicore OCaml is trying to better support:

There are some existing mechanisms to support concurrency and parallelism in OCaml:

System Concurrency Parallelism OCaml 4.11 Thread module Direct-style code can run concurrently, using pthreads OCaml runtime lock, so C threads run in parallel to a single OCaml thread Lwt / Async Code needs to use monadic interface Single threaded but interleaves IO in parallel Functory Code needs to use Functory modules for concurrent operations like map Runs on multiple runtimes (on same host or distributed)

The solutions do not allow direct-style concurrency with OCaml code running on parallel cores. The multicore OCaml project aims to solve this limitations and allow shared-memory parallel OCaml code to be written in a direct style.

Domains and fibers/effects

There are currently two implemented parallelism & concurrency abstractions in multicore:

Note: the below is the workplan agreed with the core OCaml team, and subject to change as we progress through the upstreaming process. Contact us if it's problematic for some reason for your usecase.

The plan is to upstream this in chunks to mainline OCaml. Firstly, OCaml 5.0 will have the runtime pieces to unlock the ability to have multiple parallel threads of execution using a shared-memory runtime. This version will not have the concurrency support via effects, which we will integrate into a subsequent version of OCaml. However, the parallel runtime will allow many of the existing concurrency mechanisms to start taking advantage of some parallelism via explicit invocation.

System Concurrency Parallelism Multicore OCaml (fork of OCaml, not upstream) Concurrency via effects integrated into language Parallelism via Domain per CPU Upstream OCaml 5.0 (working title) No specific support beyond Thread yet Parallelism via Domain per CPU Upstream OCaml 5.1+ TBD Parallelism via Domain per CPU What about the Thread module?

Currently multicore does not have a functioning Thread implementation (work is ongoing see #357 & #100). We are implementing systhreads with pthreads sharing a domain as described in issue #357 and implemented in PR #381 this will give a compatibility abstraction in addition to domains and fibres/effects:

It is currently open what the story is for the legacy Thread module beyond a compatibility layer and how its primitives should interwork with domains and effects/fibers.

What happens with blocking (C) calls?

The current situation is:

This is an area subject to ongoing work, for example see #100. One idea is that it could be desirable to present blocking C calls as effects; thus allowing rich schedulers to be written outside the runtime.

How many domains should run on a host?

The GC is designed to work best when num_domains <= num_cores, as the runtime has additional state per-domain to manage the garbage collector. There are synchronisations required between domains during a minor collection and the end of a major cycle. Therefore, although domains map to system (p)threads, they are considered a more heavyweight abstraction in OCaml.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4