Skip to content

Commit 32fadf8

Browse files
committed
HB experiment
1 parent 54801c4 commit 32fadf8

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

bench/bench_run.ocaml5.ml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,34 @@ module Multififo = Picos_mux_multififo
44

55
let run_one_multififo ~budgetf ~n_domains ~n () =
66
let context = ref (Obj.magic ()) in
7+
let per_threads = Array.make n_domains (Obj.magic ()) in
8+
9+
let iters = if n < 1_000_000 then 1_000_000 / n else 1 in
710

811
let before _ = context := Multififo.context () in
912
let init _ = !context in
10-
let work i context =
11-
if i <> 0 then Multififo.runner_on_this_thread context
12-
else ignore @@ Multififo.run ~context @@ fun () -> Run.for_n n ignore
13+
let wrap i context action =
14+
if i = 0 then Multififo.run ~context action
15+
else
16+
Multififo.with_per_thread context @@ fun per_thread ->
17+
per_threads.(i) <- per_thread;
18+
action ()
19+
in
20+
let work i _context =
21+
if i <> 0 then Multififo.next per_threads.(i)
22+
else
23+
for _ = 1 to iters do
24+
Run.for_n n ignore
25+
done
1326
in
1427

1528
let config =
1629
Printf.sprintf "%d mfifo%s, run_n %d" n_domains
1730
(if n_domains = 1 then "" else "s")
1831
n
1932
in
20-
Times.record ~budgetf ~n_domains ~before ~init ~work ()
21-
|> Times.to_thruput_metrics ~n ~singular:"ignore" ~config
33+
Times.record ~budgetf ~n_domains ~before ~init ~wrap ~work ()
34+
|> Times.to_thruput_metrics ~n:(n * iters) ~singular:"ignore" ~config
2235

2336
let run_suite ~budgetf =
2437
Util.cross [ 1; 2; 4; 8 ]

lib/picos_mux.multififo/picos_mux_multififo.mli

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,10 @@ val run_on :
7373
7474
The optional [forbid] argument defaults to [false] and determines whether
7575
propagation of cancelation is initially allowed. *)
76+
77+
(**/**)
78+
79+
type per_thread
80+
81+
val with_per_thread : t -> (per_thread -> 'a) -> 'a
82+
val next : per_thread -> unit

0 commit comments

Comments
 (0)