Skip to content

Commit 0959004

Browse files
committed
document how many threads are used for work in Ws_pool
1 parent 75e5284 commit 0959004

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/core/fifo_pool.mli

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ val create : (unit -> t, _) create_args
2929
(** [create ()] makes a new thread pool.
3030
@param on_init_thread
3131
called at the beginning of each new thread in the pool.
32-
@param min
33-
minimum size of the pool. See {!Pool.create_args}. The default is
34-
[Domain.recommended_domain_count()], ie one worker per CPU core. On OCaml
35-
4 the default is [4] (since there is only one domain).
32+
@param num_threads
33+
number of worker threads. See {!Ws_pool.create} for more details.
3634
@param on_exit_thread called at the end of each worker thread in the pool.
3735
@param name name for the pool, used in tracing (since 0.6) *)
3836

src/core/ws_pool.mli

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
(** Work-stealing thread pool.
22
33
A pool of threads with a worker-stealing scheduler. The pool contains a
4-
fixed number of threads that wait for work items to come, process these, and
5-
loop.
4+
fixed number of worker threads that wait for work items to come, process
5+
these, and loop.
66
77
This is good for CPU-intensive tasks that feature a lot of small tasks. Note
88
that tasks will not always be processed in the order they are scheduled, so
@@ -15,8 +15,8 @@
1515
in it to stop (after they finish their work), and wait for them to stop.
1616
1717
The threads are distributed across a fixed domain pool (whose size is
18-
determined by {!Domain.recommended_domain_count} on OCaml 5, and simply the
19-
single runtime on OCaml 4). *)
18+
determined by {!Domain.recommended_domain_count}. See {!create} for more
19+
details. *)
2020

2121
include module type of Runner
2222

@@ -36,8 +36,14 @@ val create : (unit -> t, _) create_args
3636
@param num_threads
3737
size of the pool, ie. number of worker threads. It will be at least [1]
3838
internally, so [0] or negative values make no sense. The default is
39-
[Domain.recommended_domain_count()], ie one worker thread per CPU core. On
40-
OCaml 4 the default is [4] (since there is only one domain).
39+
[Domain.recommended_domain_count()], ie one worker thread per CPU core.
40+
41+
Note that specifying [num_threads=n] means that the degree of parallelism is
42+
at most [n]. This behavior is different than the one of [Domainslib], see
43+
https://github.com/c-cube/moonpool/issues/41 for context.
44+
45+
If you want to use all cores, use [Domain.recommended_domain_count()].
46+
4147
@param on_exit_thread called at the end of each thread in the pool
4248
@param name
4349
a name for this thread pool, used if tracing is enabled (since 0.6) *)

0 commit comments

Comments
 (0)