• Stars
    star
    147
  • Rank 251,347 (Top 5 %)
  • Language
  • Created almost 3 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A collection of libraries, experiments and ideas relating to OCaml 5 (multicore + effects)

Awesome Multicore OCaml

A collection of libraries, experiments and ideas relating to OCaml 5 (multicore + effects). With the merging of the main multicore-ocaml branch into OCaml trunk, a parallel and effectful world is fast approaching.

This repository collects useful libraries, ideas and experiments relating to the use of Multicore OCaml features (primarily parallelism with domains and direct-style code with effects).

For contributing, see the guide.

If you are wondering what even is Multicore OCaml, you could start by watching KC's keynote at ICFP 2022. To know more about how Multicore OCaml evolved over the years, see this video from 2014 about Multicore OCaml by Stephen Dolan and co., then one on how to parallelise your OCaml code and how we can adapt the existing ecosystem to support Multicore OCaml.

For understanding effects in OCaml 5 you can watch KC Sivaramakrishnan's Effective Programming in OCaml 5 talk and also Thomas Leonard's talk at the 2021 OCaml Workshop on Experiences with Effects. Note both videos use a syntax for effects that will not exist in OCaml 5.00 (see also ppx_effects).

For more resources like this, check the Multicore OCaml wiki.

There's a WIP PR to start submoduling repositories so it can be a one-stop shop for taking OCaml 5.00 for a spin, see the PR.

Table of Contents

Installation

OCaml 5 is out! The compiler can be obtained with the following instructions on Linux and Mac machines.

λ opam update
λ opam switch create 5.0.0
λ eval $(opam env)

Libraries

Eio

Repository: https://github.com/ocaml-multicore/eio

Eio implements an effects-based direct-style IO stack for multicore OCaml. It supports multiple backends including a performant io-uring one and a portable libuv backend. A 0.1 release is now available from opam-repository.

Affect

Repository: https://erratique.ch/software/affect

Affect provides composable concurrency primitives for OCaml using the effect handlers available in OCaml 5.0. Affect should be seen as an experiment at that point.

Domainslib

Repository: https://github.com/ocaml-multicore/domainslib

Domainslib provides data-structures for parallel programming on top of multicore primitives. This includes a work-stealing task pool and channels for inter-domain communication.

Lockfree

Repository: https://github.com/ocaml-multicore/lockfree

Lock-free is collection of non-blocking data structures for multicore OCaml.

Lwt Support

Some useful and relevant OCaml.5 x Lwt discussions:

Lwt_eio

Repository: https://github.com/talex5/lwt_eio

Lwt_eio provides an "lwt engine" using Eio making it possible to use both Eio and Lwt in the same codebase. A 0.1 release is now available from opam-repository.

Lwt_domain

Repository: https://github.com/ocsigen/lwt

Lwt now has a package called lwt-domain. This provides useful functions for programming with Lwt and Domainslib.

Async Support

Async_eio

Repository: https://github.com/talex5/async_eio

Async_eio allows running Async and Eio code together in a single domain. It allows converting existing code to Eio incrementally.

Parany

Repository: https://github.com/UnixJunkie/parany/tree/domains

The Parany git branch called "domains" is compatible with multicore-ocaml.

OCaml Processor

Repository: https://github.com/haesbaert/ocaml-processor

The library allows you to query the processor topology as well as set the processor affinity for the current process.

cohttp-eio

Repository: https://github.com/mirage/ocaml-cohttp/tree/master/cohttp-eio

cohttp-eio is a HTTP client and server library built using eio. It enables monad-less, direct style programming of multi-core capable HTTP web server and client applications. Monads be gone.

mirage-crypto-rng-eio

Repository: https://github.com/mirage/mirage-crypto/tree/main/rng/eio

mirage-crypto-rng-eio allows to use various crypto functions in an eio application.

Js_of_ocaml

Repository: https://github.com/ocsigen/js_of_ocaml

js_of_ocaml supports effects through CPS transformations - this means one can start running effects in browsers! Implementation details can be found in Jérôme Vouillon 's PR

ocaml-tls

Repository: https://github.com/mirleft/ocaml-tls

tls_eio supports effectful operations using Eio.

Testing

Multicoretests

Repository: https://github.com/jmid/multicoretests

Experimental property-based tests of (parts of) the OCaml multicore compiler. The project contains a randomized testsuite of OCaml 5.0 based on QCheck and two reusable testing libraries Lin and STM.

Tooling

Olly

Repository: https://github.com/sadiqj/runtime_events_tools

A collection of observability tools around the runtime events tracing system introduced in OCaml 5.0.

Eio-console

Repository: https://github.com/patricoferris/eio-console

Eio-console provides an application for monitoring running programs. This works in the browser, communicating information over a websocket.

TSan

Repository: https://github.com/OlivierNicole/ocaml-tsan

ThreadSanitizer (TSan) is an effective approach to locate data races in parallel code. This extended version of the OCaml compiler generates instrumented executables that will print error reports if a data race is detected.

Experiments

Dream

Repository: https://github.com/talex5/dream/tree/eio

See also the draft PR that uses Dream, Eio and lwt_eio to provide a direct-style interface to Dream.

Ppx_effects

Repository: https://github.com/CraigFe/ppx_effects

The effects in OCaml 5 will not support a dedicated syntax, but plans exist for this perhaps once the effects are typed. Until then this ppx provides an approximation to the proposed syntax.

Gemini Protocol

Repository: https://gitlab.com/talex5/gemini-eio

The gemini protocol implemented in direct-style using eio.

Multi-shot Continuations

Repository: https://github.com/dhil/ocaml-multicont

Built on top of the continuations in Multicore OCaml, ocaml-multicont provides a library for using continuations that can be applied more than once. See also this discussion on discuss.

Mirage networking experiments

Repository: https://github.com/TheLortex/networking-experiments

Goal is to port Mirage's TCP/IP stack on top of OCaml 5's effects for more manageable async code.

capnp-rpc

Cap'n Proto is a capability-based RPC system with bindings for many languages. The Eio port switches capnp-rpc from Lwt to Eio.

gRPC

gRPC is a high performance, open source, general RPC framework that puts mobile and HTTP/2 first. The Eio port adds native Eio support for OCaml gRPC.

Ideas

Even less further on than experiments, the ideas section contains projects that would benefit from the features of Multicore OCaml.

Non-blocking Codec

Repository: https://github.com/dbuenzli/nbcodec

Many libraries and tools written in the nbcodec style would benefit from continuations given by effect handlers in Multicore OCaml, including libraries like jsonm or xmlm perhaps.

Resources

Wiki

The Multicore OCaml Wiki contains a lot of useful information from design decisions to examples. Two notable repositories are:

Papers

Talks

Discuss Threads

Recently, there has been a lot of great discussion on discuss.ocaml.org around OCaml 5, in particular what the ramifications of adding effects to the language will have to the ecosystem:

Monthlies

The OCaml monthlies are available on discuss: https://discuss.ocaml.org/tag/multicore-monthly

Benchmarks

Sandmark

Repository: https://github.com/ocaml-bench/sandmark

Sandmark is a suite of OCaml benchmarks and a collection of tools to configure different compiler variants, run and visualise the results.

Sandmark nightly runs the Sandmark benchmarks and visualises results: https://sandmark.tarides.com/?app=Home

Http Benchmarks

Repository: https://github.com/ocaml-multicore/retro-httpaf-bench

A collection of HTTP servers including ones in Go, Rust, multiple OCaml implementations and OCaml with effects.

More Repositories

1

ocaml-multicore

Multicore OCaml
OCaml
763
star
2

ocaml-effects-tutorial

Concurrent Programming with Effect Handlers
OCaml
660
star
3

eio

Effects-based direct-style IO for multicore OCaml
OCaml
555
star
4

effects-examples

Examples to illustrate the use of algebraic effects in Multicore OCaml
OCaml
423
star
5

parallel-programming-in-multicore-ocaml

Tutorial on Multicore OCaml parallel programming with domainslib
OCaml
283
star
6

ocaml5-tutorial

A hands-on tutorial on the new parallelism features in OCaml 5
OCaml
200
star
7

saturn

Lock-free data structures for multicore OCaml
OCaml
197
star
8

domainslib

Parallel Programming over Domains
OCaml
171
star
9

reagents

Reagents for multicore OCaml
OCaml
126
star
10

kcas

Software Transactional Memory for OCaml
OCaml
107
star
11

picos

Interoperable effects based concurrency
OCaml
86
star
12

meio

Monitor Eio programs
OCaml
78
star
13

ocaml-uring

Bindings to io_uring for OCaml
OCaml
62
star
14

multicore-opam

OPAM repo for OCaml multicore development
53
star
15

multicoretests

PBT testsuite and libraries for testing multicore OCaml
OCaml
37
star
16

lwt_eio

Use Lwt libraries from within Eio
OCaml
34
star
17

dscheck

Experimental model checker for testing concurrent algorithms
OCaml
33
star
18

eventlog-tools

Tools for the runtime tracing in OCaml 4.11.0 and higher
OCaml
31
star
19

multicore-talks

Repository containing slides and examples from the 2020 OCaml Workshop talk on "Parallelising your OCaml code with Multicore OCaml"
TeX
30
star
20

ocaml-iomux

Io multiplexers bindings for ocaml (poll/kqueue/epoll and so on)
OCaml
28
star
21

retro-httpaf-bench

Benchmarking environment for http servers
Jupyter Notebook
21
star
22

icfp-2023-eio-tutorial

Lwt to Eio tutorial
OCaml
20
star
23

ocaml-tsan

Race detection in OCaml using the ThreadSanitizer runtime analysis.
OCaml
20
star
24

par_incr

Parallel version of incremental library
OCaml
19
star
25

ocaml-iocp

OCaml bindings to Windows' IOCP API
OCaml
17
star
26

uring-trace

Visualization tool for your IO-uring workload
C
14
star
27

hdr_histogram_ocaml

C
12
star
28

tezos

Tezos running on Multicore OCaml
OCaml
12
star
29

multicore-magic

Low-level multicore utilities for OCaml
OCaml
12
star
30

domain-local-await

A scheduler independent blocking mechanism
OCaml
12
star
31

multicore-ocaml-verify

Verifying bits of Multicore OCaml implementation
Makefile
11
star
32

eio-trace

Trace visualisation tool for Eio programs
OCaml
11
star
33

parafuzz

Property-based grey-box fuzzing for Multicore OCaml
OCaml
9
star
34

backoff

Exponential backoff mechanism
OCaml
9
star
35

eio_js

Eio for JavaScript environments
OCaml
8
star
36

multicore-bench

Framework for benchmarking on multiple cores on current-bench
OCaml
8
star
37

docs

Docs
5
star
38

thread-table

A lock-free thread-safe integer keyed hash table
OCaml
5
star
39

domain-local-timeout

A scheduler independent timeout mechanism
OCaml
4
star
40

fun-ocaml-workshop

Fun OCaml workshop
OCaml
4
star
41

dwarf_validator

Tool for validating wellformedness of DWARF unwind information
Python
3
star
42

eio_browser

Eio backend for the browser
OCaml
3
star
43

single-use-event

A scheduler agnostic blocking mechanism
OCaml
1
star