Skip to content

Commit adb1f6a

Browse files
committed
Bench queues and stacks with heap allocated blocks
Queues and stacks 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 deca528 commit adb1f6a

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

bench/bench_bounded_q.ml

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

8383
let op push =
84-
if push then Bounded_q.push t 101 else Bounded_q.pop_opt t |> ignore
84+
if push then Bounded_q.push t (ref push) else Bounded_q.pop_opt t |> ignore
8585
in
8686

8787
let init _ =
@@ -113,7 +113,7 @@ let run_one ~budgetf ~n_adders ~n_takers ?(n_msgs = 50 * Util.iter_factor) () =
113113
let n = Countdown.alloc n_msgs_to_add ~domain_index ~batch:100 in
114114
if 0 < n then begin
115115
for i = 1 to n do
116-
Bounded_q.push t i
116+
Bounded_q.push t (ref i)
117117
done;
118118
work ()
119119
end

bench/bench_queue.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ module Queue = Stdlib.Queue
44
let run_one_domain ~budgetf ?(n_msgs = 50 * Util.iter_factor) () =
55
let t = Queue.create () in
66

7-
let op push = if push then Queue.push 101 t else Queue.take_opt t |> ignore in
7+
let op push =
8+
if push then Queue.push (ref push) t else Queue.take_opt t |> ignore
9+
in
810

911
let init _ =
1012
assert (Queue.is_empty t);

bench/bench_stack.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ module Stack = Stdlib.Stack
44
let run_one_domain ~budgetf ?(n_msgs = 50 * Util.iter_factor) () =
55
let t = Stack.create () in
66

7-
let op push = if push then Stack.push 101 t else Stack.pop_opt t |> ignore in
7+
let op push =
8+
if push then Stack.push (ref push) t else Stack.pop_opt t |> ignore
9+
in
810

911
let init _ =
1012
assert (Stack.is_empty t);

0 commit comments

Comments
 (0)