mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-11 21:48:46 -05:00
perf: a few retries in the pool
This commit is contained in:
parent
86684c642f
commit
327045f5c5
1 changed files with 13 additions and 9 deletions
22
src/pool.ml
22
src/pool.ml
|
|
@ -39,10 +39,12 @@ let run (self : t) (f : task) : unit =
|
||||||
|
|
||||||
try
|
try
|
||||||
(* try each queue with a round-robin initial offset *)
|
(* try each queue with a round-robin initial offset *)
|
||||||
for i = 0 to n_qs - 1 do
|
for _retry = 1 to 3 do
|
||||||
let q_idx = (i + offset) mod Array.length self.qs in
|
for i = 0 to n_qs - 1 do
|
||||||
let q = self.qs.(q_idx) in
|
let q_idx = (i + offset) mod Array.length self.qs in
|
||||||
if Bb_queue.try_push q f then raise_notrace Exit
|
let q = self.qs.(q_idx) in
|
||||||
|
if Bb_queue.try_push q f then raise_notrace Exit
|
||||||
|
done
|
||||||
done;
|
done;
|
||||||
push_wait ()
|
push_wait ()
|
||||||
with
|
with
|
||||||
|
|
@ -67,11 +69,13 @@ let worker_thread_ ~on_exn (active : bool A.t) (qs : task Bb_queue.t array)
|
||||||
|
|
||||||
let task =
|
let task =
|
||||||
try
|
try
|
||||||
for i = 0 to num_qs - 1 do
|
for _retry = 1 to 3 do
|
||||||
let q = qs.((offset + i) mod num_qs) in
|
for i = 0 to num_qs - 1 do
|
||||||
match Bb_queue.try_pop ~force_lock:false q with
|
let q = qs.((offset + i) mod num_qs) in
|
||||||
| Some f -> raise_notrace (Got_task f)
|
match Bb_queue.try_pop ~force_lock:false q with
|
||||||
| None -> ()
|
| Some f -> raise_notrace (Got_task f)
|
||||||
|
| None -> ()
|
||||||
|
done
|
||||||
done;
|
done;
|
||||||
pop_blocking ()
|
pop_blocking ()
|
||||||
with Got_task f -> f
|
with Got_task f -> f
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue