You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Change data structures names for user-ergonomy (treiber_stack -> stack for example)
- Uniformize queue interface and doc
- Add CONTRIBUTING file and complete test/README.md
# `Saturn` — parallelism-safe data structures for Multicore OCaml
3
2
4
-
A collection of Concurrent Lockfree Data Structures for OCaml 5. It contains:
3
+
---
5
4
6
-
*[Treiber Stack](src/treiber_stack.mli) A classic multi-producer multi-consumer stack, robust and flexible. Recommended starting point when needing LIFO structure.
7
-
8
-
*[Michael-Scott Queue](src/michael_scott_queue.mli) A classic multi-producer multi-consumer queue, robust and flexible. Recommended starting point when needing FIFO structure. It is based on [Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue Algorithms](https://www.cs.rochester.edu/~scott/papers/1996_PODC_queues.pdf).
5
+
A collection of parallelism-safe data structures for OCaml 5. It contains:
9
6
10
-
*[Chase-Lev Work-Stealing Deque](src/ws_deque.mli) Single-producer, multi-consumer dynamic-size double-ended queue (deque) (see [Dynamic circular work-stealing deque](https://dl.acm.org/doi/10.1145/1073970.1073974) and [Correct and efficient work-stealing for weak memory models](https://dl.acm.org/doi/abs/10.1145/2442516.2442524)). 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.
11
-
12
-
*[SPSC Queue](src/spsc_queue.mli) 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.
13
-
14
-
*[MPMC Relaxed Queue](src/mpmc_relaxed_queue.mli) 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.
15
-
16
-
*[MPSC Queue](src/mpsc_queue.mli) A multi-producer, single-consumer, thread-safe queue without support for cancellation. This makes a good data structure for a scheduler's run queue. It is used in [Eio](https://github.com/ocaml-multicore/eio). It is a single consumer version of the queue described in [Implementing lock-free queues](https://people.cs.pitt.edu/~jacklange/teaching/cs2510-f12/papers/implementing_lock_free.pdf).
|[Treiber Stack](src/treiber_stack.mli)| A classic multi-producer multi-consumer stack, robust and flexible. Recommended starting point when needing LIFO structure ||
10
+
|[Michael-Scott Queue](src/michael_scott_queue.mli)| A classic multi-producer multi-consumer queue, robust and flexible. Recommended starting point when needing FIFO structure. |[Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue Algorithms](https://www.cs.rochester.edu/~scott/papers/1996_PODC_queues.pdf)|
11
+
|[Chase-Lev Work-Stealing Deque](src/ws_deque.mli)| 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](https://dl.acm.org/doi/10.1145/1073970.1073974) and [Correct and efficient work-stealing for weak memory models](https://dl.acm.org/doi/abs/10.1145/2442516.2442524)) |
12
+
|[SPSC Queue](src/spsc_queue.mli)| 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. ||
13
+
|[MPMC Relaxed Queue](src/mpmc_relaxed_queue.mli)| 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. ||
14
+
|[MPSC Queue](src/mpsc_queue.mli)| A multi-producer, single-consumer, thread-safe queue without support for cancellation. This makes a good data structure for a scheduler's run queue. It is used in [Eio](https://github.com/ocaml-multicore/eio). | It is a single consumer version of the queue described in [Implementing lock-free queues](https://people.cs.pitt.edu/~jacklange/teaching/cs2510-f12/papers/implementing_lock_free.pdf). |
17
15
18
16
## Usage
19
17
20
-
lockfree can be installed from `opam`: `opam install lockfree`. Sample usage of
18
+
`Saturn` can be installed from `opam`: `opam install saturn`. Sample usage of
21
19
`Ws_deque` is illustrated below.
22
20
23
21
```ocaml
@@ -30,11 +28,26 @@ let () = Ws_deque.push q 100
30
28
let () = assert (Ws_deque.pop q = 100)
31
29
```
32
30
31
+
## Tests
32
+
33
+
Several kind of tests are provided for each data structure:
34
+
35
+
- unitary tests and `qcheck` tests: check semantics and expected behaviors with
36
+
one and more domains;
37
+
-`STM` tests: check _linearizability_ for two domains (see
Execute `make bench` from root of the repository to run the standard set of benchmarks. The output is in JSON, as it is intended to be consumed by ocaml-benchmark CI (in progress).
5
+
Execute `make bench` from root of the repository to run the standard set of
6
+
benchmarks. The output is in JSON, as it is intended to be consumed by
7
+
ocaml-benchmark CI (in progress).
6
8
7
-
# Specific structures
9
+
# Specific structures
8
10
9
11
Some benchmarks expose commandline interface targeting particular structures:
0 commit comments