package lockfree
All checked builds passInstall
dune-project
Dependency
Authors
Maintainers
Sources
sha256=565f758aef2134af4c242e82df91e6262ace6fdebe25b070de01c07bc9fd49b7
sha512=f27242e825588ec569417ef9bf510975b1ee17b7bc78ed54c879b2f6d731e03c300f38ee20fef6bc45ed715e59a4a3bdb61cbccefe817570f916fe20ce4cefeb
Description
README
lockfree — Lock-free data structures for Multicore OCaml
A collection of Concurrent Lockfree Data Structures for OCaml 5. It contains:
- Treiber Stack A classic multi-producer multi-consumer stack, robust and flexible. Recommended starting point when needing LIFO structure.
- Michael-Scott Queue 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.
- Chase-Lev Work-Stealing Deque Single-producer, multi-consumer dynamic-size double-ended queue (deque) (see Dynamic circular work-stealing deque and Correct and efficient work-stealing for weak memory models). 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.
- SPSC Queue 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 Relaxed Queue 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 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. It is a single consumer version of the queue described in Implementing lock-free queues.
Usage
lockfree can be installed from opam: opam install lockfree. Sample usage of Ws_deque is illustrated below.
module Ws_deque = Ws_deque.M
let q = Ws_deque.create ()
let () = Ws_deque.push q 100
let () = assert (Ws_deque.pop q = 100)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 of more lockfree data structures appreciated! Please create issues/PRs to this repo.
Dependencies (5)
-
yojson
>= "2.0.2" -
alcotest
>= "1.6.0" -
domain_shims
>= "0.1.0" -
dune
>= "3.0" -
ocaml
>= "4.12"
Dev Dependencies (4)
-
dscheck
with-test & >= "0.0.1" -
qcheck-alcotest
with-test & >= "0.18.1" -
qcheck-stm
with-test & >= "0.1" -
qcheck
with-test & >= "0.18.1"
Optional Dependencies
None
Used by (1)
-
domainslib
= "0.5.0"
Conflicts
None
Build status
Results of building lockfree with each compiler on check.ci.ocaml.org, run of against opam-repository 8a77e58. All results for this package.
Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.
| Version | OCaml 4.11 | OCaml 4.14 | OCaml 5.2 | OCaml 5.4 | OCaml 5.5 |
|---|---|---|---|---|---|
| 0.3.1 (this version) | n/a | good | good | good | good |
- good Package successfully built
- partial One of the dependencies failed to build
- bad Package failed to build
- n/a Package is not available in this environment
- internal Internal failure