tweak retry thresholds in pool

This commit is contained in:
Simon Cruanes 2023-10-25 00:28:19 -04:00
parent 3bfc4cdcc7
commit ef05146e03
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -66,6 +66,12 @@ exception Got_task of task
type around_task = AT_pair : (t -> 'a) * (t -> 'a -> unit) -> around_task
(** How many times in a row do we try to read the next local task? *)
let run_self_task_max_retry = 5
(** How many times in a row do we try to do work-stealing? *)
let steal_attempt_max_retry = 5
let worker_thread_ (self : state) (runner : t) (w : worker_state) ~on_exn
~around_task : unit =
let (AT_pair (before_task, after_task)) = around_task in
@ -90,8 +96,9 @@ let worker_thread_ (self : state) (runner : t) (w : worker_state) ~on_exn
pop_retries := 0;
run_task task
| None ->
Domain_.relax ();
incr pop_retries;
if !pop_retries > 10 then continue := false
if !pop_retries > run_self_task_max_retry then continue := false
done
in
@ -125,7 +132,7 @@ let worker_thread_ (self : state) (runner : t) (w : worker_state) ~on_exn
incr steal_attempts;
Domain_.relax ();
if !steal_attempts > 10 then (
if !steal_attempts > steal_attempt_max_retry then (
steal_attempts := 0;
let task = Bb_queue.pop self.main_q in
run_task task