Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
clecat committed Jan 30, 2024
1 parent 4562e70 commit 4a268a6
Show file tree
Hide file tree
Showing 132 changed files with 1,564 additions and 1,032 deletions.
3 changes: 2 additions & 1 deletion bench/irmin-pack/trace_replay.ml
Original file line number Diff line number Diff line change
Expand Up @@ -475,12 +475,13 @@ module Make (Store : Store) = struct
[%logs.app
"Will %scheck commit hashes against reference."
(if check_hash then "" else "NOT ")];
Eio.Switch.run @@ fun sw ->
let commit_seq =
open_commit_sequence config.number_of_commits_to_replay
config.path_conversion config.replay_trace_path
in
let root = Filename.concat config.artefacts_path "root" in
let repo, on_commit, on_end = Store.create_repo ~root ext_config in
let repo, on_commit, on_end = Store.create_repo ~sw ~root ext_config in
prepare_artefacts_dir config.artefacts_path;
let stat_path = Filename.concat config.artefacts_path "stat_trace.repr" in
let c =
Expand Down
7 changes: 6 additions & 1 deletion bench/irmin-pack/trace_replay_intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ module type Store = sig
type on_commit := int -> Hash.t -> unit
type on_end := unit -> unit

val create_repo : root:string -> store_config -> Repo.t * on_commit * on_end
val create_repo :
sw:Eio.Switch.t ->
root:string ->
store_config ->
Repo.t * on_commit * on_end

val split : repo -> unit
val add_volume : repo -> unit
val gc_wait : repo -> unit
Expand Down
172 changes: 89 additions & 83 deletions bench/irmin-pack/tree.ml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ module type Store = sig
type on_commit := int -> Hash.t -> unit
type on_end := unit -> unit

val create_repo : root:string -> store_config -> Repo.t * on_commit * on_end
val create_repo :
sw:Eio.Switch.t ->
root:string ->
store_config ->
Repo.t * on_commit * on_end

type stats := Irmin_pack_unix.Stats.Latest_gc.stats

Expand Down Expand Up @@ -124,8 +128,9 @@ module Bench_suite (Store : Store) = struct

let run_large config =
reset_stats ();
Eio.Switch.run @@ fun sw ->
let root = config.store_dir in
let repo, on_commit, on_end = Store.create_repo ~root config in
let repo, on_commit, on_end = Store.create_repo ~sw ~root config in
let result, () =
Trees.add_large_trees config.width config.nlarge_trees
|> add_commits ~message:"Playing large mode" repo config.ncommits
Expand All @@ -144,8 +149,9 @@ module Bench_suite (Store : Store) = struct

let run_chains config =
reset_stats ();
Eio.Switch.run @@ fun sw ->
let root = config.store_dir in
let repo, on_commit, on_end = Store.create_repo ~root config in
let repo, on_commit, on_end = Store.create_repo ~sw ~root config in
let result, () =
Trees.add_chain_trees config.depth config.nchain_trees
|> add_commits ~message:"Playing chain mode" repo config.ncommits
Expand Down Expand Up @@ -212,12 +218,12 @@ module Make_store_mem (Conf : Irmin_pack.Conf.S) = struct

let indexing_strategy = Irmin_pack.Indexing_strategy.minimal

let create_repo ~root _config =
let create_repo ~sw ~root _config =
let conf =
Irmin_pack.config ~readonly:false ~fresh:true ~indexing_strategy root
in
prepare_artefacts_dir root;
let repo = Store.Repo.v conf in
let repo = Store.Repo.v ~sw conf in
let on_commit _ _ = () in
let on_end () = () in
(repo, on_commit, on_end)
Expand All @@ -242,7 +248,7 @@ module Make_store_pack (Conf : Irmin_pack.Conf.S) = struct

let indexing_strategy = Irmin_pack.Indexing_strategy.minimal

let create_repo ~root (config : store_config) =
let create_repo ~sw ~root (config : store_config) =
let lower_root =
if config.add_volume_every > 0 then Some (Filename.concat root "lower")
else None
Expand All @@ -252,7 +258,7 @@ module Make_store_pack (Conf : Irmin_pack.Conf.S) = struct
~lower_root root
in
prepare_artefacts_dir root;
let repo = Store.Repo.v conf in
let repo = Store.Repo.v ~sw conf in
let on_commit _ _ = () in
let on_end () = () in
(repo, on_commit, on_end)
Expand Down Expand Up @@ -303,82 +309,82 @@ type suite_elt = {
let suite : suite_elt list =
List.rev
[
{
mode = `Read_trace;
speed = `Quick;
run =
(fun config ->
let config =
{ config with inode_config = (32, 256); store_type = `Pack }
in
let (module Store) = store_of_config config in
Store.run_read_trace config);
};
{
mode = `Read_trace;
speed = `Slow;
run =
(fun config ->
let config =
{ config with inode_config = (32, 256); store_type = `Pack }
in
let (module Store) = store_of_config config in
Store.run_read_trace config);
};
{
mode = `Chains;
speed = `Quick;
run =
(fun config ->
let config =
{ config with inode_config = (32, 256); store_type = `Pack }
in
let (module Store) = store_of_config config in
Store.run_chains config);
};
{
mode = `Chains;
speed = `Slow;
run =
(fun config ->
let config =
{ config with inode_config = (2, 5); store_type = `Pack }
in
let (module Store) = store_of_config config in
Store.run_chains config);
};
{
mode = `Large;
speed = `Quick;
run =
(fun config ->
let config =
{ config with inode_config = (32, 256); store_type = `Pack }
in
let (module Store) = store_of_config config in
Store.run_large config);
};
{
mode = `Large;
speed = `Slow;
run =
(fun config ->
let config =
{ config with inode_config = (2, 5); store_type = `Pack }
in
let (module Store) = store_of_config config in
Store.run_large config);
};
{
mode = `Read_trace;
speed = `Custom;
run =
(fun config ->
let (module Store) = store_of_config config in
Store.run_read_trace config);
};
]
[
{
mode = `Read_trace;
speed = `Quick;
run =
(fun config ->
let config =
{ config with inode_config = (32, 256); store_type = `Pack }
in
let (module Store) = store_of_config config in
Store.run_read_trace config);
};
{
mode = `Read_trace;
speed = `Slow;
run =
(fun config ->
let config =
{ config with inode_config = (32, 256); store_type = `Pack }
in
let (module Store) = store_of_config config in
Store.run_read_trace config);
};
{
mode = `Chains;
speed = `Quick;
run =
(fun config ->
let config =
{ config with inode_config = (32, 256); store_type = `Pack }
in
let (module Store) = store_of_config config in
Store.run_chains config);
};
{
mode = `Chains;
speed = `Slow;
run =
(fun config ->
let config =
{ config with inode_config = (2, 5); store_type = `Pack }
in
let (module Store) = store_of_config config in
Store.run_chains config);
};
{
mode = `Large;
speed = `Quick;
run =
(fun config ->
let config =
{ config with inode_config = (32, 256); store_type = `Pack }
in
let (module Store) = store_of_config config in
Store.run_large config);
};
{
mode = `Large;
speed = `Slow;
run =
(fun config ->
let config =
{ config with inode_config = (2, 5); store_type = `Pack }
in
let (module Store) = store_of_config config in
Store.run_large config);
};
{
mode = `Read_trace;
speed = `Custom;
run =
(fun config ->
let (module Store) = store_of_config config in
Store.run_read_trace config);
};
]
let get_suite suite_filter =
List.filter
Expand Down
3 changes: 2 additions & 1 deletion examples/client_batch.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ module Client = Irmin_client_unix.Make (Store)
module Error = Irmin_client.Error

let main () =
Eio.Switch.run @@ fun sw ->
let info () = Client.Info.empty in
let uri = Uri.of_string Sys.argv.(1) in
let client = Client.connect uri in
let client = Client.connect ~sw uri in

let main = Client.main client in
Client.set_exn ~info main [ "testing" ] "testing";
Expand Down
3 changes: 2 additions & 1 deletion examples/custom_graphql.ml
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ module Server =
Irmin_graphql_unix.Server.Make_ext (Store) (Remote) (Custom_types)

let main () =
Eio.Switch.run @@ fun sw ->
Config.init ();
let config = Irmin_git.config Config.root in
let repo = Store.Repo.v config in
let repo = Store.Repo.v ~sw config in
let server = Server.v repo in
let src = "localhost" in
let port = 9876 in
Expand Down
3 changes: 2 additions & 1 deletion examples/custom_merge.ml
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ let print_logs name t =
Fmt.pr "-----------\n%s:\n-----------\n%a%!" name (Irmin.Type.pp Log.t) logs

let main () =
Eio.Switch.run @@ fun sw ->
Config.init ();
let repo = Store.Repo.v config in
let repo = Store.Repo.v ~sw config in
let t = Store.main repo in

(* populate the log with some random messages *)
Expand Down
5 changes: 3 additions & 2 deletions examples/custom_storage.ml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ functor

(** Initialisation / Closing *)

let v config =
let v ~sw:_ config =
let init_size = Irmin.Backend.Conf.get config Hashtbl_config.init_size in
{ t = Tbl.create init_size; l = Eio.Mutex.create () }

Expand Down Expand Up @@ -87,7 +87,8 @@ let config ?(config = Hashtbl_config.empty) ?(init_size = 42) () =
Irmin.Backend.Conf.add config Hashtbl_config.init_size init_size

let main () =
let repo = Store.Repo.v (config ()) in
Eio.Switch.run @@ fun sw ->
let repo = Store.Repo.v ~sw (config ()) in
let main = Store.main repo in
let info () = Store.Info.v 0L in
let key = "Hello" in
Expand Down
9 changes: 5 additions & 4 deletions examples/deploy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -101,33 +101,34 @@ let main () =
state when needed.\n"
cmd cmd cmd cmd Config.root
in
Eio.Switch.run @@ fun sw ->
if Array.length Sys.argv <> 2 then help ()
else
match Sys.argv.(1) with
| "provision" ->
(let repo = Store.Repo.v config in
(let repo = Store.Repo.v ~sw config in
provision repo);
Printf.printf
"The VM is now provisioned. Run `%s configure` to simulate a sysadmin \n\
configuration.\n"
cmd
| "configure" ->
(let repo = Store.Repo.v config in
(let repo = Store.Repo.v ~sw config in
configure repo);
Printf.printf
"The VM is now configured. Run `%s attack` to simulate an attack by \
an \n\
intruder.\n"
cmd
| "attack" ->
(let repo = Store.Repo.v config in
(let repo = Store.Repo.v ~sw config in
attack repo);
Printf.printf
"The VM has been attacked. Run `%s revert` to revert the VM state to \
a safe one.\n"
cmd
| "revert" ->
let repo = Store.Repo.v config in
let repo = Store.Repo.v ~sw config in
revert repo
| _ -> help ()

Expand Down
3 changes: 2 additions & 1 deletion examples/fold.ml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ end
let main () =
let ps name = Fmt.(pf stdout "\n%s\n" name) in
ps "Demo of how tree folders visit nodes.";
let repo = Store.Repo.v config in
Eio.Switch.run @@ fun sw ->
let repo = Store.Repo.v ~sw config in
let main_b = Store.main repo in
Store.set_exn ~info:(info "add c1") main_b [ "c1" ] "c1";
Store.set_exn ~info:(info "add c2") main_b [ "c2" ] "c2";
Expand Down
6 changes: 4 additions & 2 deletions examples/irmin-pack/gc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,10 @@ let run_gc config repo tracker =
Tracker.mark_next_gc_commit tracker

let run_experiment config =
Eio.Switch.run @@ fun sw ->
let num_of_commits = 200_000 in
let gc_every = 1_000 in
let repo = Store.Repo.v config in
let repo = Store.Repo.v ~sw config in
let tracker = Tracker.v () in
(* Create commits *)
let _ =
Expand All @@ -186,7 +187,8 @@ let run_experiment config =
()

let () =
Eio_main.run @@ fun _env ->
Eio_main.run @@ fun env ->
Irmin_pack_unix.Io.set_env (Eio.Stdenv.fs env);
Printf.printf "== RUN 1: deleting discarded data ==\n";
run_experiment Repo_config.config;
Printf.printf "== RUN 2: archiving discarded data ==\n";
Expand Down
Loading

0 comments on commit 4a268a6

Please sign in to comment.