Skip to content

Commit d1413c9

Browse files
committed
Avoid creating lots of or unnecessary systhreads on OCaml 4
1 parent 220a382 commit d1413c9

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

bench/bench_bounded_q.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ open Picos_structured
33
open Picos_sync
44
module Queue = Stdlib.Queue
55

6+
let is_ocaml4 = String.starts_with ~prefix:"4." Sys.ocaml_version
7+
68
module Bounded_q : sig
79
type 'a t
810

@@ -119,7 +121,7 @@ let run_one ~budgetf ~n_adders ~n_takers ?(n_msgs = 10 * Util.iter_factor) () =
119121
let wrap _ () = Scheduler.run in
120122
let work domain_index () =
121123
Flock.join_after @@ fun () ->
122-
Flock.fork yielder;
124+
if not is_ocaml4 then Flock.fork yielder;
123125
if domain_index < n_adders then
124126
let rec work () =
125127
let n = Countdown.alloc n_msgs_to_add ~domain_index ~batch:100 in

bench/bench_spawn.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
open Multicore_bench
22
open Picos
33

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

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

0 commit comments

Comments
 (0)