Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small cleanups #2062

Merged
merged 1 commit into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 3 additions & 34 deletions src/irmin-pack/unix/file_manager.ml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ struct
mutable prefix : Prefix.t option;
mutable mapping : Mapping_file.t option;
index : Index.t;
mutable mapping_consumers : after_reload_consumer list;
mutable dict_consumers : after_reload_consumer list;
mutable suffix_consumers : after_flush_consumer list;
indexing_strategy : Irmin_pack.Indexing_strategy.t;
Expand All @@ -71,9 +70,6 @@ struct
let+ () = Index.close t.index in
()

let register_mapping_consumer t ~after_reload =
t.mapping_consumers <- { after_reload } :: t.mapping_consumers

let register_dict_consumer t ~after_reload =
t.dict_consumers <- { after_reload } :: t.dict_consumers

Expand Down Expand Up @@ -342,7 +338,6 @@ struct
mapping;
use_fsync;
index;
mapping_consumers = [];
dict_consumers = [];
suffix_consumers = [];
indexing_strategy;
Expand Down Expand Up @@ -400,17 +395,6 @@ struct
[read_error] to [ [>read_error] ]. *)
match res with Ok () -> Ok () | Error (#Errs.t as e) -> Error e
in
(* Step 6. Notify the mapping consumers that they must reload *)
let* () =
let res =
List.fold_left
(fun acc { after_reload } -> Result.bind acc after_reload)
(Ok ()) t.mapping_consumers
in
(* The following dirty trick casts the result from
[read_error] to [ [>read_error] ]. *)
match res with Ok () -> Ok () | Error (#Errs.t as e) -> Error e
in
Ok ()

(* File creation ********************************************************** *)
Expand Down Expand Up @@ -611,7 +595,6 @@ struct
use_fsync;
indexing_strategy;
index;
mapping_consumers = [];
dict_consumers = [];
suffix_consumers = [];
root;
Expand Down Expand Up @@ -667,20 +650,7 @@ struct
let* () = reopen_suffix t ~generation ~end_offset:suffix_end_offset in
let span1 = Mtime_clock.count c0 |> Mtime.Span.to_us in

(* Step 2. Reload mapping consumers (i.e. dispatcher) *)
let* () =
let res =
List.fold_left
(fun acc { after_reload } -> Result.bind acc after_reload)
(Ok ()) t.mapping_consumers
in
(* The following dirty trick casts the result from
[read_error] to [ [>read_error] ]. *)
match res with Ok () -> Ok () | Error (#Errs.t as e) -> Error e
in
let span2 = Mtime_clock.count c0 |> Mtime.Span.to_us in

(* Step 3. Update the control file *)
(* Step 2. Update the control file *)
let* () =
let pl = Control.payload t.control in
let pl =
Expand All @@ -702,10 +672,9 @@ struct
Control.set_payload t.control pl
in

let span3 = Mtime_clock.count c0 |> Mtime.Span.to_us in
let span2 = Mtime_clock.count c0 |> Mtime.Span.to_us in
[%log.debug
"Gc reopen files, reload map, update control: %.0fus, %.0fus, %.0fus"
span1 (span2 -. span1) (span3 -. span2)];
"Gc reopen files, update control: %.0fus, %.0fus" span1 (span2 -. span1)];
Ok ()

let write_gc_output ~root ~generation output =
Expand Down
3 changes: 0 additions & 3 deletions src/irmin-pack/unix/file_manager_intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,6 @@ module type S = sig

Is a no-op if the control file did not change. *)

val register_mapping_consumer :
t -> after_reload:(unit -> (unit, Errs.t) result) -> unit

val register_dict_consumer :
t -> after_reload:(unit -> (unit, Errs.t) result) -> unit

Expand Down