-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
173 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
(** Lock-free bounded Queue. | ||
This module implements a lock-free bounded queue based on Michael-Scott's queue | ||
algorithm. Adding a capacity to this algorithm adds a general overhead to the | ||
operations, and thus, it is recommended to use the unbounded queue | ||
{!Saturn.Queue} if you don't need it. | ||
*) | ||
|
||
include Bounded_queue_intf.BOUNDED_QUEUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
(** Optimized lock-free bounded Queue. | ||
This module implements a lock-free bounded queue based on Michael-Scott's queue | ||
algorithm. Adding a capacity to this algorithm adds a general overhead to the | ||
operations, and thus, it is recommended to use the unbounded queue | ||
{!Saturn.Queue} if you don't need it. | ||
*) | ||
|
||
include Bounded_queue_intf.BOUNDED_QUEUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
(** | ||
Michael-Scott classic lock-free multi-producer multi-consumer queue. | ||
All functions are lockfree. It is the recommended starting point | ||
when needing FIFO structure. It is inspired by {{: | ||
https://www.cs.rochester.edu/~scott/papers/1996_PODC_queues.pdf} | ||
Simple, Fast, and Practical Non-Blocking and Blocking Concurrent | ||
Queue Algorithms}. | ||
If you need a [length] function, you can use the bounded queue | ||
{!Saturn.Bounded_queue} instead with maximun capacity (default value). | ||
However, this adds a general overhead to the operation. | ||
*) | ||
|
||
include Michael_scott_queue_intf.MS_QUEUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,16 @@ | ||
(** | ||
Optimized Michael-Scott lock-free multi-producer multi-consumer | ||
queue. | ||
All functions are lockfree. It is the recommended starting point | ||
when needing FIFO structure. It is inspired by {{: | ||
https://www.cs.rochester.edu/~scott/papers/1996_PODC_queues.pdf} | ||
Simple, Fast, and Practical Non-Blocking and Blocking Concurrent | ||
Queue Algorithms}. | ||
If you need a [length] function, you can use the bounded queue | ||
{!Saturn.Bounded_queue} instead with maximun capacity (default value). | ||
However, this adds a general overhead to the operation. | ||
*) | ||
|
||
include Michael_scott_queue_intf.MS_QUEUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,22 +26,70 @@ Copyright (c) 2017, Nicolas ASSOUAD <[email protected]> | |
######## | ||
*) | ||
|
||
(** Lock-free data structures for Multicore OCaml *) | ||
(** Parallelism-safe data structures for Multicore OCaml *) | ||
|
||
(** {1 Useful Information} | ||
{2 Domain-Specific Data Structures} | ||
Some data structures are optimized for specific domain configurations. These | ||
restrictions enhance performance but must be adhered to for maintaining safety | ||
properties. These limitations are documented and often reflected in the data | ||
structure's name. For example, a single-consumer queue should only have one | ||
domain performing `pop` operations at any time. | ||
For more details, refer to this | ||
{{: https://github.com/ocaml-multicore/saturn/blob/main/doc/domain-role.md}{document}}. | ||
{2 Composability} | ||
Composability is the ability to combine functions while preserving their | ||
properties, such as atomic consistency (linearizability) and progress | ||
guarantees (e.g., lock-freedom). Saturn's data structures, however, are not | ||
composable. | ||
For more details, refer to this | ||
{{: https://github.com/ocaml-multicore/saturn/blob/main/doc/composability.md}{document}}. | ||
*) | ||
|
||
(** {2 Unsafe Data Structures} | ||
Some data structures have both a normal and an {b unsafe} version. The | ||
{b unsafe} version uses `Obj.magic`, which may be unsafe with flambda2 | ||
optimizations. | ||
The unsafe version is provided because certain optimizations require features | ||
not currently available in OCaml, such as arrays of atomics or atomic fields | ||
in records. It is recommended to use the normal version unless performance | ||
requirements necessitate the unsafe version. *) | ||
|
||
(** {1 Data structures} *) | ||
|
||
(** {2 Collections} *) | ||
|
||
module Htbl = Htbl | ||
module Htbl_unsafe = Htbl_unsafe | ||
module Skiplist = Skiplist | ||
module Bag = Bag | ||
|
||
(** {2 Queues} *) | ||
|
||
module Queue = Michael_scott_queue | ||
module Queue_unsafe = Michael_scott_queue_unsafe | ||
module Stack = Treiber_stack | ||
module Bounded_stack = Bounded_stack | ||
module Bounded_queue = Bounded_queue | ||
module Bounded_queue_unsafe = Bounded_queue_unsafe | ||
module Work_stealing_deque = Ws_deque | ||
module Single_consumer_queue = Mpsc_queue | ||
module Single_prod_single_cons_queue = Spsc_queue | ||
module Single_prod_single_cons_queue_unsafe = Spsc_queue_unsafe | ||
module Single_consumer_queue = Mpsc_queue | ||
module Skiplist = Skiplist | ||
|
||
(** {2 Stacks} *) | ||
|
||
module Stack = Treiber_stack | ||
module Bounded_stack = Bounded_stack | ||
|
||
(** {2 Work Stealing Deque }*) | ||
|
||
module Work_stealing_deque = Ws_deque | ||
|
||
(** {1 Other}*) | ||
|
||
module Size = Size | ||
module Htbl = Htbl | ||
module Htbl_unsafe = Htbl_unsafe | ||
module Bag = Bag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
(** Lock-free single-producer, single-consumer queue. | ||
{b Warning}: This queue does not include safety mechanisms to prevent | ||
misuse. If consumer-only functions are called concurrently by multiple | ||
domains, the queue may enter an unexpected state, due to data races | ||
and a lack of linearizability. The same goes for producer-only functions. | ||
*) | ||
|
||
include Spsc_queue_intf.SPSC_queue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
(** Optimized lock-free single-producer, single-consumer queue. | ||
{b Warning}: This queue does not include safety mechanisms to prevent | ||
misuse. If consumer-only functions are called concurrently by multiple | ||
domains, the queue may enter an unexpected state, due to data races | ||
and a lack of linearizability. The same goes for producer-only functions. | ||
*) | ||
|
||
include Spsc_queue_intf.SPSC_queue |
Oops, something went wrong.