Skip to content

Commit

Permalink
Avoid creating lots of or unnecessary systhreads on OCaml 4
Browse files Browse the repository at this point in the history
  • Loading branch information
polytypic committed Aug 19, 2024
1 parent 220a382 commit d1413c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion bench/bench_bounded_q.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ open Picos_structured
open Picos_sync
module Queue = Stdlib.Queue

let is_ocaml4 = String.starts_with ~prefix:"4." Sys.ocaml_version

module Bounded_q : sig
type 'a t

Expand Down Expand Up @@ -119,7 +121,7 @@ let run_one ~budgetf ~n_adders ~n_takers ?(n_msgs = 10 * Util.iter_factor) () =
let wrap _ () = Scheduler.run in
let work domain_index () =
Flock.join_after @@ fun () ->
Flock.fork yielder;
if not is_ocaml4 then Flock.fork yielder;
if domain_index < n_adders then
let rec work () =
let n = Countdown.alloc n_msgs_to_add ~domain_index ~batch:100 in
Expand Down
5 changes: 4 additions & 1 deletion bench/bench_spawn.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
open Multicore_bench
open Picos

let is_ocaml4 = String.starts_with ~prefix:"4." Sys.ocaml_version

let factor =
Util.iter_factor
* if String.starts_with ~prefix:"4." Sys.ocaml_version then 1 else 10
Expand Down Expand Up @@ -31,4 +33,5 @@ let run_one ~budgetf () =
~work ()
|> Times.to_thruput_metrics ~n:n_spawns ~singular:"spawn" ~config

let run_suite ~budgetf = if Sys.int_size <= 32 then [] else run_one ~budgetf ()
let run_suite ~budgetf =
if Sys.int_size <= 32 || is_ocaml4 then [] else run_one ~budgetf ()

0 comments on commit d1413c9

Please sign in to comment.