Skip to content

Commit

Permalink
tweak retry thresholds in pool
Browse files Browse the repository at this point in the history
  • Loading branch information
c-cube committed Oct 25, 2023
1 parent 3bfc4cd commit ef05146
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/pool.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ef05146

Please sign in to comment.