• Stars
    star
    197
  • Rank 197,722 (Top 4 %)
  • Language
    OCaml
  • License
    ISC License
  • Created almost 8 years ago
  • Updated about 2 months ago

Reviews

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

Repository Details

Lock-free data structures for multicore OCaml

Saturn β€” parallelism-safe data structures for Multicore OCaml


This repository is a collection of parallelism-safe data structures for OCaml 5. They are contained in two packages:

  • Saturn that includes every data structures and should be used by default if you just want parallelism-safe data structures..
  • Saturn_lockfree that includes only lock-free data structures.

The available data structures are :

Names Names in Saturn
(in Saturn_lockfree)
What is it ? Sources
Treiber stack Stack (same) A classic multi-producer multi-consumer stack, robust and flexible. Recommended starting point when needing a LIFO structure
Michael-Scott queue Queue (same) A classic multi-producer multi-consumer queue, robust and flexible. Recommended starting point when needing a FIFO structure. Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue Algorithms
Chase-Lev Work-Stealing Dequeue Work_stealing_deque (same) Single-producer, multi-consumer dynamic-size double-ended queue (deque). Ideal for throughput-focused scheduling using per-core work distribution. Note, pop and steal follow different ordering (respectively LIFO and FIFO) and have different linearization contraints. Dynamic circular work-stealing deque and Correct and efficient work-stealing for weak memory models)
SPSC Queue Single_prod_single_
cons_queue (same)
Simple single-producer single-consumer fixed-size queue. Thread-safe as long as at most one thread acts as producer and at most one as consumer at any single point in time.
MPMC bounded relaxed queue Relaxed queue (same) Multi-producer, multi-consumer, fixed-size relaxed queue. Optimised for high number of threads. Not strictly FIFO. Note, it exposes two interfaces: a lockfree and a non-lockfree (albeit more practical) one. See the mli for details.
MPSC Queue Single_consumer_queue (same) A multi-producer, single-consumer, thread-safe queue without support for cancellation. This makes a gooddata structure for a scheduler's run queue. It is used in Eio. It is a single consumer version of the queue described in Implementing lock-free queues.

Usage

Saturn can be installed from opam: opam install saturn. Sample usage of Work_stealing_deque is illustrated below.

module Ws_deque = Work_stealing_deque.M

let q = Ws_deque.create ()

let () = Ws_deque.push q 100

let () = assert (Ws_deque.pop q = 100)

Tests

Several kind of tests are provided for each data structure:

  • unitary tests and qcheck tests: check semantics and expected behaviors with one and more domains;
  • STM tests: check linearizability for two domains (see multicoretests library);
  • dscheck: checks non-blocking property for as many domains as wanted (for two domains most of the time). See dscheck.

See test/README.md for more details.

Benchmarks

There is a number of benchmarks in bench directory. You can run them with make bench. See bench/README.md for more details.

Contributing

Contributions are appreciated! If you intend to add a new data structure, please read this before.

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

domainslib

Parallel Programming over Domains
OCaml
171
star
8

awesome-multicore-ocaml

A collection of libraries, experiments and ideas relating to OCaml 5 (multicore + effects)
147
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