Skip to content

Commit 63e6e74

Browse files
authored
Merge pull request #2233 from metanivek/lower_layer_for_tree_bench
2 parents ab57c57 + 18d33e9 commit 63e6e74

File tree

4 files changed

+42
-8
lines changed

4 files changed

+42
-8
lines changed

bench/irmin-pack/trace_replay.ml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ module Make (Store : Store) = struct
159159
mutable commits_since_start_or_gc : int;
160160
mutable latest_commit_idx : int;
161161
(** the most recent commit idx to be replayed. initial value is -1 *)
162+
mutable gc_count : int;
162163
key_per_commit_idx : (int, Store.commit_key) Hashtbl.t;
163164
}
164165

@@ -322,7 +323,7 @@ module Make (Store : Store) = struct
322323
in
323324
aux operations 0
324325

325-
let gc_actions config i commits_since_start_or_gc =
326+
let gc_actions config i commits_since_start_or_gc gc_count =
326327
let gc_enabled =
327328
(* Is GC enabled at all? *)
328329
config.gc_every > 0
@@ -357,10 +358,18 @@ module Make (Store : Store) = struct
357358
else false
358359
in
359360

361+
let time_to_add_volume =
362+
config.add_volume_every > 0
363+
&& time_to_split
364+
&& gc_count > 0
365+
&& gc_count mod config.add_volume_every = 0
366+
in
367+
360368
let really_split = gc_enabled && time_to_split in
361369
let really_start_gc = gc_enabled && time_to_start in
362370
let really_wait_gc = gc_wait_enabled && time_to_wait in
363-
(really_wait_gc, really_start_gc, really_split)
371+
let really_add_volume = time_to_add_volume in
372+
(really_wait_gc, really_start_gc, really_split, really_add_volume)
364373

365374
let add_commits config repo commit_seq on_commit on_end stats check_hash
366375
empty_blobs =
@@ -372,6 +381,7 @@ module Make (Store : Store) = struct
372381
contexts = Hashtbl.create 3;
373382
hash_corresps = Hashtbl.create 3;
374383
commits_since_start_or_gc = 0;
384+
gc_count = 0;
375385
latest_commit_idx = -1;
376386
key_per_commit_idx = Hashtbl.create 3;
377387
}
@@ -384,11 +394,12 @@ module Make (Store : Store) = struct
384394
match commit_seq () with
385395
| Seq.Nil -> on_end () >|= fun () -> i
386396
| Cons (ops, commit_seq) ->
387-
let really_wait_gc, really_start_gc, really_split =
388-
gc_actions config i t.commits_since_start_or_gc
397+
let really_wait_gc, really_start_gc, really_split, really_add_volume =
398+
gc_actions config i t.commits_since_start_or_gc t.gc_count
389399
in
390400
(* Split before GC to simulate how it is inteded to be used. *)
391401
let () = if really_split then Store.split repo in
402+
let () = if really_add_volume then Store.add_volume repo in
392403
let* () =
393404
if really_wait_gc then (
394405
[%logs.app
@@ -418,6 +429,7 @@ module Make (Store : Store) = struct
418429
(Hashtbl.find t.key_per_commit_idx t.latest_commit_idx)];
419430
let finished = function
420431
| Ok stats ->
432+
t.gc_count <- t.gc_count + 1;
421433
let commit_idx = t.latest_commit_idx in
422434
let commit_duration = commit_idx - gc_start_commit_idx in
423435
let duration =

bench/irmin-pack/trace_replay_intf.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ module Config = struct
3333
gc_every : int;
3434
gc_distance_in_the_past : int;
3535
gc_wait_after : int;
36+
add_volume_every : int;
3637
}
3738
(** Replay configuration
3839
@@ -102,6 +103,7 @@ module type Store = sig
102103
root:string -> store_config -> (Repo.t * on_commit * on_end) Lwt.t
103104

104105
val split : repo -> unit
106+
val add_volume : repo -> unit
105107
val gc_wait : repo -> unit Lwt.t
106108

107109
type stats := Irmin_pack_unix.Stats.Latest_gc.stats

bench/irmin-pack/tree.ml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type config = {
3939
gc_every : int;
4040
gc_distance_in_the_past : int;
4141
gc_wait_after : int;
42+
add_volume_every : int;
4243
}
4344

4445
module type Store = sig
@@ -61,6 +62,7 @@ module type Store = sig
6162
type stats := Irmin_pack_unix.Stats.Latest_gc.stats
6263

6364
val split : repo -> unit
65+
val add_volume : repo -> unit
6466

6567
val gc_run :
6668
?finished:((stats, string) result -> unit Lwt.t) ->
@@ -181,6 +183,7 @@ module Bench_suite (Store : Store) = struct
181183
gc_every = config.gc_every;
182184
gc_distance_in_the_past = config.gc_distance_in_the_past;
183185
gc_wait_after = config.gc_wait_after;
186+
add_volume_every = config.add_volume_every;
184187
}
185188
in
186189
if config.no_summary then
@@ -224,6 +227,7 @@ module Make_store_mem (Conf : Irmin_pack.Conf.S) = struct
224227
Lwt.return (repo, on_commit, on_end)
225228

226229
let split _repo = ()
230+
let add_volume _repo = ()
227231
let gc_wait _repo = Lwt.return_unit
228232
let gc_run ?finished:_ _repo _key = Lwt.return_unit
229233
end
@@ -242,9 +246,14 @@ module Make_store_pack (Conf : Irmin_pack.Conf.S) = struct
242246

243247
let indexing_strategy = Irmin_pack.Indexing_strategy.minimal
244248

245-
let create_repo ~root _config =
249+
let create_repo ~root (config : store_config) =
250+
let lower_root =
251+
if config.add_volume_every > 0 then Some (Filename.concat root "lower")
252+
else None
253+
in
246254
let conf =
247-
Irmin_pack.config ~readonly:false ~fresh:true ~indexing_strategy root
255+
Irmin_pack.config ~readonly:false ~fresh:true ~indexing_strategy
256+
~lower_root root
248257
in
249258
prepare_artefacts_dir root;
250259
let* repo = Store.Repo.v conf in
@@ -253,6 +262,7 @@ module Make_store_pack (Conf : Irmin_pack.Conf.S) = struct
253262
Lwt.return (repo, on_commit, on_end)
254263

255264
let split = Store.split
265+
let add_volume = Store.add_volume
256266

257267
let gc_wait repo =
258268
let* r = Store.Gc.wait repo in
@@ -395,7 +405,8 @@ let get_suite suite_filter =
395405
let main () ncommits number_of_commits_to_replay suite_filter inode_config
396406
store_type freeze_commit path_conversion depth width nchain_trees
397407
nlarge_trees replay_trace_path artefacts_path keep_store keep_stat_trace
398-
no_summary empty_blobs gc_every gc_distance_in_the_past gc_wait_after =
408+
no_summary empty_blobs gc_every gc_distance_in_the_past gc_wait_after
409+
add_volume_every =
399410
let default = match suite_filter with `Quick -> 10000 | _ -> 13315 in
400411
let number_of_commits_to_replay =
401412
Option.value ~default number_of_commits_to_replay
@@ -422,6 +433,7 @@ let main () ncommits number_of_commits_to_replay suite_filter inode_config
422433
gc_every;
423434
gc_distance_in_the_past;
424435
gc_wait_after;
436+
add_volume_every;
425437
}
426438
in
427439
Printexc.record_backtrace true;
@@ -602,6 +614,10 @@ let gc_wait_after =
602614
in
603615
Arg.(value @@ opt int 0 doc)
604616
617+
let add_volume_every =
618+
let doc = Arg.info ~doc:"Add volume ever N GCs" [ "add-volume-every" ] in
619+
Arg.(value @@ opt int 0 doc)
620+
605621
let main_term =
606622
Term.(
607623
const main
@@ -625,7 +641,8 @@ let main_term =
625641
$ empty_blobs
626642
$ gc_every
627643
$ gc_distance_in_the_past
628-
$ gc_wait_after)
644+
$ gc_wait_after
645+
$ add_volume_every)
629646
630647
let deprecated_info = (Term.info [@alert "-deprecated"])
631648
let deprecated_exit = (Term.exit [@alert "-deprecated"])

test/irmin-bench/replay.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ let replay_1_commit () =
9595
gc_every = 0;
9696
gc_distance_in_the_past = 0;
9797
gc_wait_after = 0;
98+
add_volume_every = 0;
9899
}
99100
in
100101
let+ summary = Replay.run () replay_config in
@@ -141,6 +142,7 @@ module Store_mem = struct
141142
Lwt.return (repo, on_commit, on_end)
142143
143144
let split _repo = ()
145+
let add_volume _repo = ()
144146
let gc_wait _repo = Lwt.return_unit
145147
let gc_run ?finished:_ _repo _key = Lwt.return_unit
146148
end
@@ -164,6 +166,7 @@ let replay_1_commit_mem () =
164166
gc_every = 0;
165167
gc_distance_in_the_past = 0;
166168
gc_wait_after = 0;
169+
add_volume_every = 0;
167170
}
168171
in
169172
let+ summary = Replay_mem.run () replay_config in

0 commit comments

Comments
 (0)