From a8e3ae829077140822bfdba13d0e9819ba1fb934 Mon Sep 17 00:00:00 2001 From: Vesa Karvonen Date: Sun, 18 Jan 2026 19:17:17 +0000 Subject: [PATCH] Add Htbl fill benchmark --- bench/bench_htbl.ml | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/bench/bench_htbl.ml b/bench/bench_htbl.ml index 49308e67..8f1302e5 100644 --- a/bench/bench_htbl.ml +++ b/bench/bench_htbl.ml @@ -67,8 +67,39 @@ let run_one ~budgetf ~n_domains ?(n_ops = 400 * Util.iter_factor) Times.record ~budgetf ~n_domains ~before ~init ~work () |> Times.to_thruput_metrics ~n:n_ops ~singular:"operation" ~config +let run_fill1m ~budgetf ~n_domains () = + let n_ops = 250_000 * n_domains in + let t = Htbl.create ~hashed_type:(module Key) () in + let before () = + let _ : _ Seq.t = Htbl.remove_all t in + () + in + let init i = + let k0 = i * n_ops / n_domains in + let k1 = ((i + 1) * n_ops / n_domains) - 1 in + (k0, k1) + in + let work _ (k0, k1) = + for k = k0 to k1 do + assert (Htbl.try_add t k ()) + done + in + let after () = assert (n_ops = Htbl.non_linearizable_length t) in + let config = + Printf.sprintf "%d worker%s" n_domains (if n_domains = 1 then "" else "s") + in + Times.record ~n_runs_min:19 ~budgetf ~n_domains ~before ~init ~work ~after () + |> Times.to_thruput_metrics ~n:n_ops ~singular:"add" ~config + let run_suite ~budgetf = - Util.cross [ 1; 2; 4; 8 ] [ 10; 50; 90 ] - |> List.concat_map @@ fun (n_domains, percent_mem) -> + [ 1; 2; 4; 8 ] + |> List.concat_map @@ fun n_domains -> if Picos_domain.recommended_domain_count () < n_domains then [] - else run_one ~budgetf ~n_domains ~percent_mem () + else + let basic = + [ 10; 50; 90 ] + |> List.concat_map @@ fun percent_mem -> + run_one ~budgetf ~n_domains ~percent_mem () + in + let fill1m = run_fill1m ~budgetf ~n_domains () in + basic @ fill1m