mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-10 13:14:05 -05:00
tweak retry thresholds in pool
This commit is contained in:
parent
3bfc4cdcc7
commit
ef05146e03
1 changed files with 9 additions and 2 deletions
11
src/pool.ml
11
src/pool.ml
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue