Skip to content

Commit 7460176

Browse files
committed
Bench queues with heap allocated blocks
Queues were previously benchmarked with immediate values only, which unfortunately partially hides the potential cost of write barriers related to setting and clearing elements.
1 parent 035e19c commit 7460176

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

bench/bench_bounded_q.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ let run_one_domain ~budgetf ?(n_msgs = 25 * Util.iter_factor) () =
8686
let t = Bounded_q.create () in
8787

8888
let op push =
89-
if push then Bounded_q.push t 101 else Bounded_q.pop_opt t |> ignore
89+
if push then Bounded_q.push t (ref push) else Bounded_q.pop_opt t |> ignore
9090
in
9191

9292
let init _ =
@@ -128,7 +128,7 @@ let run_one ~budgetf ~n_adders ~n_takers ?(n_msgs = 10 * Util.iter_factor) () =
128128
let n = Countdown.alloc n_msgs_to_add ~domain_index ~batch:100 in
129129
if 0 < n then begin
130130
for i = 1 to n do
131-
Bounded_q.push t i
131+
Bounded_q.push t (ref i)
132132
done;
133133
work ()
134134
end

bench/bench_mpmcq.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let run_one_domain ~budgetf ?(n_msgs = 50 * Util.iter_factor) () =
55
let t = Mpmcq.create ~padded:true () in
66

77
let op push =
8-
if push then Mpmcq.push t 101
8+
if push then Mpmcq.push t (ref push)
99
else match Mpmcq.pop_exn t with _ -> () | exception Mpmcq.Empty -> ()
1010
in
1111

@@ -41,7 +41,7 @@ let run_one ~budgetf ~n_adders ~n_takers () =
4141
let n = Countdown.alloc n_msgs_to_add ~domain_index:i ~batch:1000 in
4242
if 0 < n then begin
4343
for i = 1 to n do
44-
Mpmcq.push t i
44+
Mpmcq.push t (ref i)
4545
done;
4646
work ()
4747
end

bench/bench_mpscq.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let run_one_domain ~budgetf ?(n_msgs = 50 * Util.iter_factor) () =
55
let t = Mpscq.create ~padded:true () in
66

77
let op push =
8-
if push then Mpscq.push t 101
8+
if push then Mpscq.push t (ref push)
99
else match Mpscq.pop_exn t with _ -> () | exception Mpscq.Empty -> ()
1010
in
1111

@@ -40,7 +40,7 @@ let run_one ~budgetf ~n_adders () =
4040
let n = Countdown.alloc n_msgs_to_add ~domain_index:i ~batch:1000 in
4141
if 0 < n then begin
4242
for i = 1 to n do
43-
Mpscq.push t i
43+
Mpscq.push t (ref i)
4444
done;
4545
work ()
4646
end

bench/bench_stream.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let run_one_domain ~budgetf ?(n_msgs = 50 * Util.iter_factor) () =
77
let cursor = ref (Stream.tap t) in
88

99
let op push =
10-
if push then Stream.push t 101
10+
if push then Stream.push t (ref push)
1111
else
1212
match Stream.peek_opt !cursor with
1313
| None -> ()
@@ -44,7 +44,7 @@ let run_one ~budgetf ~n_pusher () =
4444
let n = Util.alloc n_msgs_to_add in
4545
if 0 < n then begin
4646
for i = 1 to n do
47-
Stream.push t i
47+
Stream.push t (ref i)
4848
done;
4949
work ()
5050
end

0 commit comments

Comments
 (0)