Skip to content

Commit

Permalink
fix: never go above the recommended domain count
Browse files Browse the repository at this point in the history
Before the dedicated IO Thread, we could spin up to
`recmomended_domain_count () - 1` additional scheduler threads, but now
we have one less.

If the number of workers is set manually, it'll be capped to the max
possible workers.
  • Loading branch information
leostera committed Dec 24, 2023
1 parent a70ce60 commit 1164315
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions riot/riot.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ let shutdown () =
let pool = _get_pool () in
Scheduler.Pool.shutdown pool

let run ?(rnd = Random.State.make_self_init ())
?(workers = max 0 (Stdlib.Domain.recommended_domain_count () - 1)) main =
let run ?(rnd = Random.State.make_self_init ()) ?workers main =
let max_workers = Int.max 0 (Stdlib.Domain.recommended_domain_count () - 2) in
let workers =
match workers with Some w -> Int.min w max_workers | None -> max_workers
in

Log.debug (fun f -> f "Initializing Riot runtime...");
Printexc.record_backtrace true;
Pid.reset ();
Expand Down

0 comments on commit 1164315

Please sign in to comment.