Skip to content

Commit

Permalink
Merge pull request #2166 from patricoferris/mtime.2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
metanivek authored Jun 9, 2023
2 parents 0075198 + e20503e commit 3222d26
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 17 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
- Change behavior of `Irmin.Conf.key` to disallow duplicate key names by
default. Add `allow_duplicate` optional argument to override. (@metanivek,
#2252)

### Changed

- **irmin**
- Lower bounds for `mtime` is now `2.0.0` (@patricoferris, #2166)

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion bench/irmin-pack/bench_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
open Irmin.Export_for_backends

let c0 = Mtime_clock.counter ()
let now_us () = Mtime_clock.count c0 |> Mtime.Span.to_us
let now_us () = Mtime.span_to_us (Mtime_clock.count c0)
let last = ref (now_us ())

let dt_us () =
Expand Down
5 changes: 3 additions & 2 deletions bench/irmin-pack/dune
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(executables
(names main)
(public_names bench-pack)
(modules main import)
(modules main)
(package irmin-bench)
(preprocess
(pps ppx_irmin.internal ppx_repr))
Expand Down Expand Up @@ -42,7 +42,8 @@
trace_replay
trace_replay_intf
tezos_history_metrics
trace_stat_summary_cb)
trace_stat_summary_cb
import)
(preprocess
(pps ppx_irmin.internal ppx_repr ppx_deriving.enum))
(libraries
Expand Down
6 changes: 4 additions & 2 deletions bench/irmin-pack/trace_collection.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
A module [Make_replayable] has yet to be implemented. *)

open Lwt.Syntax
module Mtime = Import.Mtime

(** Make state trace collector. *)
module Make_stat (Store : Irmin.Generic_key.KV) = struct
Expand Down Expand Up @@ -200,7 +201,8 @@ module Make_stat (Store : Irmin.Generic_key.KV) = struct

let short_op_end { t0; writer; _ } short_op =
let duration =
Mtime_clock.count t0 |> Mtime.Span.to_s |> Int32.bits_of_float
Mtime_clock.count t0 |> fun span ->
Mtime.span_to_s span |> Int32.bits_of_float
in
let op =
match short_op with
Expand Down Expand Up @@ -238,7 +240,7 @@ module Make_stat (Store : Irmin.Generic_key.KV) = struct
t.commit_before <- (stats_before, store_before)

let commit_end t tree =
let duration = Mtime_clock.count t.t0 |> Mtime.Span.to_s in
let duration = Mtime_clock.count t.t0 |> Mtime.span_to_s in
let duration = duration |> Int32.bits_of_float in
let stats_after = Bag_of_stats.create t.store_path t.prev_merge_durations in
t.prev_merge_durations <- Index.Stats.((get ()).merge_durations);
Expand Down
2 changes: 1 addition & 1 deletion bench/irmin-pack/trace_stat_summary_utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ let create_pp_seconds examples =
Float.neg_infinity examples
in
let finite_pp =
if absmax >= 60. then fun ppf v -> Mtime.Span.pp_float_s ppf v
if absmax >= 60. then fun ppf v -> Fmt.uint64_ns_span ppf (Int64.of_float v)
else if absmax < 100. *. 1e-12 then fun ppf v ->
Format.fprintf ppf "%.3e s" v
else if absmax < 100. *. 1e-9 then fun ppf v ->
Expand Down
2 changes: 1 addition & 1 deletion irmin-bench.opam
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ depends: [
"progress" {>="0.2.1"}
"fpath" {with-test}
"bentov"
"mtime" {< "2.0.0"}
"mtime" {>= "2.0.0"}
"ppx_deriving"
"alcotest" {with-test}
"rusage"
Expand Down
2 changes: 1 addition & 1 deletion irmin-containers.opam
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ depends: [
"irmin-fs" {= version}
"ppx_irmin" {= version}
"lwt" {>= "5.3.0"}
"mtime" {< "2.0.0"}
"mtime" {>= "2.0.0"}
"alcotest" {with-test}
"alcotest-lwt" {with-test}
]
Expand Down
2 changes: 1 addition & 1 deletion irmin-git.opam
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ depends: [
"uri"
"mimic"
"irmin-test" {with-test & = version}
"mtime" {with-test & >= "1.0.0" & < "2.0.0"}
"mtime" {with-test & >= "2.0.0"}
"alcotest" {with-test}
"irmin-watcher" {>= "0.2.0"}
]
Expand Down
2 changes: 1 addition & 1 deletion irmin-pack.opam
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ depends: [
"fmt"
"logs"
"lwt" {>= "5.4.0"}
"mtime" {< "2.0.0"}
"mtime" {>= "2.0.0"}
"cmdliner"
"optint" {>= "0.1.0"}
"checkseum"
Expand Down
2 changes: 1 addition & 1 deletion irmin-test.opam
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ depends: [
"ocaml" {>= "4.02.3"}
"dune" {>= "2.9.0"}
"alcotest-lwt" {>= "1.5.0"}
"mtime" {>= "1.0.0" & < "2.0.0"}
"mtime" {>= "2.0.0"}
"astring"
"fmt"
"jsonm"
Expand Down
2 changes: 1 addition & 1 deletion irmin.opam
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ depends: [
"logs" {>= "0.5.0"}
"bheap" {>= "2.0.0"}
"astring"
"mtime" {>= "1.0.0" & < "2.0.0"}
"mtime" {>= "2.0.0"}
"bigstringaf" { >= "0.2.0" }
"ppx_irmin" {= version}
"hex" {with-test}
Expand Down
4 changes: 2 additions & 2 deletions src/irmin-pack/unix/file_manager.ml
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ struct
reopen_suffix t ~chunk_start_idx ~chunk_num
~appendable_chunk_poff:pl.appendable_chunk_poff
in
let span1 = Mtime_clock.count c0 |> Mtime.Span.to_us in
let span1 = Mtime_clock.count c0 |> Mtime.span_to_us in

(* Step 2. Update the control file *)
let* () =
Expand Down Expand Up @@ -928,7 +928,7 @@ struct
Lower.swap ~volume ~generation ~volume_num:pl.volume_num lower)
in

let span2 = 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, update control: %.0fus, %.0fus" span1 (span2 -. span1)];
Ok ()
Expand Down
2 changes: 1 addition & 1 deletion src/irmin-pack/unix/store.ml
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ module Maker (Config : Conf.S) = struct
let node : 'a Node.t = (contents, node) in
let commit : 'a Commit.t = (node, commit) in
let on_success res =
let s = Mtime_clock.count c0 |> Mtime.Span.to_s in
let s = Mtime_clock.count c0 |> Mtime.span_to_s in
[%log.info "[pack] batch completed in %.6fs" s];
t.during_batch <- false;
File_manager.flush t.fm |> Errs.raise_if_error;
Expand Down
2 changes: 1 addition & 1 deletion src/irmin-test/store_watch.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module Make (Log : Logs.LOG) (Zzz : Sleep) (S : Generic_key) = struct
let sleep_t = min sleep_t 1. in
Lwt.pause () >>= fun () -> Zzz.sleep sleep_t

let now_s () = Mtime.Span.to_s (Mtime_clock.elapsed ())
let now_s () = Mtime.span_to_s (Mtime_clock.elapsed ())

(* Re-apply [f] at intervals of [sleep_t] while [f] raises exceptions and
[while_ ()] holds. *)
Expand Down
7 changes: 7 additions & 0 deletions src/irmin/import.ml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ module List = struct
aux l idx []
end

module Mtime = struct
include Mtime

let span_to_s span = Mtime.Span.to_float_ns span *. 1e-9
let span_to_us span = Mtime.Span.to_float_ns span *. 1e-3
end

module Seq = struct
include Seq
(** @closed *)
Expand Down
2 changes: 1 addition & 1 deletion src/irmin/logging.ml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ let reporter :
in
let ppf = match level with Logs.App -> Fmt.stdout | _ -> Fmt.stderr in
let with_stamp h tags k fmt =
let dt = Mtime.Span.to_us (Clock.count start_time) in
let dt = Mtime.span_to_us (Clock.count start_time) in
let source_pos_text, source_pos_colour =
match tags with
| None -> (Logs.Src.name src, `Magenta)
Expand Down

0 comments on commit 3222d26

Please sign in to comment.