From 0f4e115bc0a4ccb648b5cacc0cac69c38ac07d37 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Mon, 10 Jul 2023 01:31:12 -0400 Subject: [PATCH] doc --- src/fork_join.mli | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/fork_join.mli b/src/fork_join.mli index ef8435dd..6c3bff37 100644 --- a/src/fork_join.mli +++ b/src/fork_join.mli @@ -50,6 +50,17 @@ val for_ : ?chunk_size:int -> int -> (int -> int -> unit) -> unit let() = assert (Atomic.get total_sum = 4950) ]} + Note how we still compute a local sum sequentially in [(fun low high -> …)], + before combining it wholesale into [total_sum]. When the chunk size is large, + this can have a dramatic impact on the synchronization overhead. + + When [chunk_size] is not provided, the library will attempt to guess a value + that keeps all cores busy but runs as few tasks as possible to reduce + the synchronization overhead. + + Use [~chunk_size:1] if you explicitly want to + run each iteration of the loop in its own task. + @since NEXT_RELEASE {b NOTE} this is only available on OCaml 5. *)