diff --git a/CHANGES.md b/CHANGES.md index 2577a57e443..f8f84193c47 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 diff --git a/bench/irmin-pack/bench_common.ml b/bench/irmin-pack/bench_common.ml index 7ba4b5dcbe6..c2c01d11cb0 100644 --- a/bench/irmin-pack/bench_common.ml +++ b/bench/irmin-pack/bench_common.ml @@ -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 () = diff --git a/bench/irmin-pack/dune b/bench/irmin-pack/dune index b95a7cc6246..36ae897f1cc 100644 --- a/bench/irmin-pack/dune +++ b/bench/irmin-pack/dune @@ -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)) @@ -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 diff --git a/bench/irmin-pack/trace_collection.ml b/bench/irmin-pack/trace_collection.ml index 20b7b032090..94a51eed8b0 100644 --- a/bench/irmin-pack/trace_collection.ml +++ b/bench/irmin-pack/trace_collection.ml @@ -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 @@ -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 @@ -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); diff --git a/bench/irmin-pack/trace_stat_summary_utils.ml b/bench/irmin-pack/trace_stat_summary_utils.ml index e35846aed40..8e109b11446 100644 --- a/bench/irmin-pack/trace_stat_summary_utils.ml +++ b/bench/irmin-pack/trace_stat_summary_utils.ml @@ -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 -> diff --git a/irmin-bench.opam b/irmin-bench.opam index aa60de96936..2e02920cf5d 100644 --- a/irmin-bench.opam +++ b/irmin-bench.opam @@ -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" diff --git a/irmin-containers.opam b/irmin-containers.opam index 672c2acd8fd..c0bb403cc44 100644 --- a/irmin-containers.opam +++ b/irmin-containers.opam @@ -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} ] diff --git a/irmin-git.opam b/irmin-git.opam index 5d892b47be6..a50451c80ca 100644 --- a/irmin-git.opam +++ b/irmin-git.opam @@ -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"} ] diff --git a/irmin-pack.opam b/irmin-pack.opam index cc2483e17d2..ed7460fde9b 100644 --- a/irmin-pack.opam +++ b/irmin-pack.opam @@ -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" diff --git a/irmin-test.opam b/irmin-test.opam index 58e423b572c..30506a2d8e6 100644 --- a/irmin-test.opam +++ b/irmin-test.opam @@ -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" diff --git a/irmin.opam b/irmin.opam index fe3bf05a5ed..f5521eb51e4 100644 --- a/irmin.opam +++ b/irmin.opam @@ -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} diff --git a/src/irmin-pack/unix/file_manager.ml b/src/irmin-pack/unix/file_manager.ml index fa296a80a74..88815325fc2 100644 --- a/src/irmin-pack/unix/file_manager.ml +++ b/src/irmin-pack/unix/file_manager.ml @@ -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* () = @@ -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 () diff --git a/src/irmin-pack/unix/store.ml b/src/irmin-pack/unix/store.ml index 8fbd44f1cdd..17c58e5a343 100644 --- a/src/irmin-pack/unix/store.ml +++ b/src/irmin-pack/unix/store.ml @@ -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; diff --git a/src/irmin-test/store_watch.ml b/src/irmin-test/store_watch.ml index eb14afc329d..5b19ebed0d2 100644 --- a/src/irmin-test/store_watch.ml +++ b/src/irmin-test/store_watch.ml @@ -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. *) diff --git a/src/irmin/import.ml b/src/irmin/import.ml index 6fe68be9472..814f31812af 100644 --- a/src/irmin/import.ml +++ b/src/irmin/import.ml @@ -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 *) diff --git a/src/irmin/logging.ml b/src/irmin/logging.ml index f398ae412f5..f7e3d186ad7 100644 --- a/src/irmin/logging.ml +++ b/src/irmin/logging.ml @@ -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)