perf: limit number of work queues in pool

This commit is contained in:
Simon Cruanes 2023-06-14 11:21:11 -04:00
parent 1d5e962d87
commit 483392986c
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -88,6 +88,14 @@ let worker_thread_ ~on_exn (active : bool A.t) (qs : task Bb_queue.t array)
let default_thread_init_exit_ ~dom_id:_ ~t_id:_ () = () let default_thread_init_exit_ ~dom_id:_ ~t_id:_ () = ()
(** We want a reasonable number of queues. Even if your system is
a beast with hundreds of cores, trying
to work-steal through hundreds of queues will have a cost.
Hence, we limit the number of queues to at most 32 (number picked
via the ancestral technique of the pifomètre). *)
let max_queues = 32
let create ?(on_init_thread = default_thread_init_exit_) let create ?(on_init_thread = default_thread_init_exit_)
?(on_exit_thread = default_thread_init_exit_) ?(thread_wrappers = []) ?(on_exit_thread = default_thread_init_exit_) ?(thread_wrappers = [])
?(on_exn = fun _ _ -> ()) ?min:(min_threads = 1) ?(per_domain = 0) () : t = ?(on_exn = fun _ _ -> ()) ?min:(min_threads = 1) ?(per_domain = 0) () : t =
@ -102,7 +110,7 @@ let create ?(on_init_thread = default_thread_init_exit_)
let active = A.make true in let active = A.make true in
let qs = let qs =
let num_qs = min num_domains num_threads in let num_qs = min (min num_domains num_threads) max_queues in
Array.init num_qs (fun _ -> Bb_queue.create ()) Array.init num_qs (fun _ -> Bb_queue.create ())
in in